Tuesday, December 9, 2025

Removing an Application Deployment in SCCM Using PowerShell

Managing deployments in Microsoft Configuration Manager (SCCM) can sometimes require quick cleanup — especially when an application is no longer needed or was deployed to the wrong collection. Instead of navigating through the SCCM console, PowerShell provides a fast and reliable way to remove deployments with a single command.

In this post, we’ll look at a simple PowerShell cmdlet that removes a specific application deployment from a collection.


The PowerShell Command

Remove-CMDeployment -ApplicationName "XXX" -CollectionName "XXX" -Force

This cmdlet targets a specific application and removes its deployment from the selected collection.


How the Command Works

  • -ApplicationName "XXX"
    Specifies the application whose deployment you want to remove. Replace this with the exact application name in SCCM.

  • -CollectionName "XXX"
    Identifies the SCCM collection from which the deployment should be removed.

  • -Force
    Executes the command without prompting for confirmation — useful for automation or scripting.


Example Use Case

If you deployed an older version of an app by mistake, you could instantly remove it:

Remove-CMDeployment -ApplicationName "7-Zip 19.00" -CollectionName "All Workstations" -Force

Within seconds, the deployment is withdrawn — no console navigation required.


Why Use PowerShell?

  • Faster than using the console

  • Great for automation and repeatable tasks

  • Reduces human error

  • Ideal for environments with many collections or frequent updates


PowerShell continues to be one of the most efficient tools for SCCM administrators. With commands like Remove-CMDeployment, managing and cleaning up deployments becomes quick, consistent, and hassle-free.

If you'd like, I can also create a longer version, add screenshots, or format this for a platform like WordPress or Medium.

How to Remove a Specific Package Deployment from a Collection Using PowerShell in Configuration Manager

Removing a Specific Package Deployment from a Collection Using PowerShell

Managing deployments in Microsoft Configuration Manager (SCCM/MECM) is easier and faster when using PowerShell. If you need to remove a package deployment from a specific collection, you can do it with a single command — no console navigation required.


PowerShell Command

To remove a deployment using the package ID and collection name, use:

Remove-CMPackageDeployment -PackageID "XXX" -CollectionName "xxx" -Force

What this does

  • -PackageID specifies the exact package you want to remove.

  • -CollectionName identifies the targeted device or user collection.

  • -Force removes the deployment without prompting for confirmation.


When to Use This Command

This is especially useful when:

  • Cleaning up old or duplicate deployments

  • Updating packages and removing older versions

  • Automating deployment maintenance tasks


Prerequisites

Make sure you:

  • Run PowerShell from the ConfigMgr Console (which loads the proper module)

  • Have permissions to modify deployments in MECM


Summary

With one simple PowerShell command, you can quickly remove a package deployment from a specific collection:

Remove-CMPackageDeployment -PackageID "XXX" -CollectionName "xxx" -Force

This approach saves time, reduces errors, and fits perfectly into automation workflows.

Monday, November 24, 2025

Retrieve All SCCM/MECM Applications That Have No Active Deployments || ConfigMgr

 

Finding Unused SCCM Applications with SQL: A Quick Reporting Query

In every SCCM (Microsoft Endpoint Configuration Manager) environment, unused or unreferenced applications gradually accumulate over time. These unused applications clutter the console, consume storage, and complicate administrative tasks such as audits, cleanup, and migration.

To help identify such applications, here is a SQL query that lists SCCM applications that exist in the environment but are not deployed, not referenced in task sequences, and have no dependent relationships. This report is very useful for cleanup and housekeeping activities.


SQL Query: Identify Unused/Orphaned SCCM Applications

select apps.DisplayName as 'ApplicationName',apps.Description, apps.Softwareversion as 'Version',apps.Manufacturer,apps.createdby, apps.Datelastmodifiedby, pkg.PackageID, CASE pkg.PackageType WHEN 0 THEN 'Package' WHEN 3 THEN 'Driver' WHEN 4 THEN 'TaskSequence' WHEN 5 THEN 'SoftwareUpdate' WHEN 6 THEN 'DeviceSettings' WHEN 7 THEN 'Virtual' WHEN 8 THEN 'Application' WHEN 257 THEN 'Image' WHEN 258 THEN 'BootImage' WHEN 259 THEN 'OSInstall' END AS 'PackageType', apps.NumberOfDeploymentTypes as 'NoofDT', apps.NumberOfDeployments, apps.NumberOfDependentTs from fn_ListLatestApplicationCIs(1033) apps left join v_TaskSequencePackageReferences tspr on tspr.ObjectID = apps.ModelName left join vSMS_ApplicationAssignment ass on ass.AssignedCI_UniqueID = apps.CI_UniqueID left join v_Package pkg on pkg.SecurityKey = apps.ModelName where PackageType = 8 and apps.IsLatest=1 and ass.AssignmentName IS NULL and tspr.PackageID IS NULL and apps.NumberOfDeployments = 0 and apps.NumberOfDependentTs = 0 and apps.IsLatest=1 order by apps.DisplayName

What This Query Does

This SQL query helps you quickly identify SCCM applications that are:

✔ Not deployed to any collection

apps.NumberOfDeployments = 0

✔ Not referenced in any task sequence

tspr.PackageID IS NULL

✔ Not depended on by other task sequences

apps.NumberOfDependentTs = 0

✔ Not assigned to any users or devices

ass.AssignmentName IS NULL

✔ Latest version of the application only

apps.IsLatest = 1

✔ Applications only (not packages, drivers, OS images, etc.)

PackageType = 8

This gives you a clean, filtered list of orphaned or unused applications that can be reviewed for retirement or cleanup.


Columns Returned by the Report

The result includes helpful administrative fields:

  • ApplicationName – Display name of the application

  • Description – App description (if provided)

  • Version – Software version

  • Manufacturer – Vendor or publisher

  • CreatedBy / DateLastModifiedBy – Who created or modified the app

  • PackageID – Package ID associated with the application

  • PackageType – Interpreted using the CASE statement

  • NoofDT – Number of deployment types

  • NumberOfDeployments – Total deployments

  • NumberOfDependentTs – Task sequences that depend on it

These fields help administrators understand the lifecycle and usage of each application.


Why This Report Is Useful

1. Cleanup and Housekeeping

This report helps identify applications that can safely be deleted or reviewed because they are not actively used.

2. Migration Projects

Before migrating to:

  • A new SCCM site

  • Intune

  • A new infrastructure
    This report helps detect unused apps to avoid migrating unnecessary content.

3. Compliance and Inventory

Auditors or admins can verify which apps are actively managed vs. inactive.

4. Environment Optimization

Removing unused apps improves:

  • Console performance

  • Content library organization

  • Storage utilization


How to Run the Query

  1. Open SQL Server Management Studio (SSMS)

  2. Connect to the SCCM site database (e.g., CM_ABC)

  3. Open a new query window

  4. Paste the SQL query

  5. Execute and review the output