You can run SCCM Powershell cmdlet and scripts from the SCCM console or from a Windows PowerShell session. This is very useful to do stuff in SCCM without using the console. You can do pretty much anything using Powershell. When you get used to it, you can write more complex scripts to automate and save lots of time.
Supported versions of SCCM’s current branch support Windows PowerShell version 5.1. Starting in version 2010, the Configuration Manager PowerShell cmdlet library supports PowerShell 7.
If you’re not familiar with PowerShell and SCCM, the easiest way to connect to your site is to use the shortcut in the console :

PS SCD:\>
Once connected, you can enter any SCCM Powershell cmdlet to control your site. At the time of this writing, there are hundreds of cmdlets available.
As with any Powershell cmdlet, the cmdlet is pretty self-explanatory for example the GET-CMDevice cmdlet will “GET” a “CM” (Configuration Manager), “Device” information.
Get-CMDevice -Name "CM01"
Output :

So here’s a couple of examples to get you started :
Get-CMDevice – Get a Configuration Manager device.
Instead of this in the console :

Run this :
Get-CMDevice -Name "CM01"
Output :

We will also use the Get-CMDevice cmdlet to list all non-clients. The last part Select-Object Name will only return the name of the non-clients (without the rest of the properties).
Get-CMDevice -Fast | Where-Object { $_.IsClient -eq $false } | Select-Object Name
Output :

Clear-CMPxeDeployment – Clears the status of the most recent PXE deployment in Configuration Manager.
Instead of this in the console :

Run this :
Clear-CMPxeDeployment -DeviceCollectionId "YourCollectionID"
Unlock-CMObject – Release a SEDO lock on an object.
If you have a lock object and see this in the SCCM console :

Run this :
Unlock-CMObject -InputObject $(Get-CMApplication -Name "Application Name")
TIP: You can change “Get-CMApplication” for “Get-CMTaskSequence” if you want to unlock a Task Sequence for example.
Microsoft supports only 200 collections using incremental updates. To list all collections that have incremental update enabled.
Instead of this (on each collection) :

Run This :
Get-CMDeviceCollection | Where{$_.RefreshType -eq 6} | Select Name
Output :

The Add-CMDeviceCollectionDirectMembershipRule cmdlet adds a direct membership rule to a device collection. A direct membership rule lets you explicitly choose the members of the device collection.
Instead of this in the console :

Run This :
Add-CMDeviceCollectionDirectMembershipRule -CollectionId "SCD00123" -ResourceId 2088162048
TIP: You can get the ResourceID by adding the RedsourceID column to the console

This command uses the Get-CMDeployment and Remove-CMDeployment to gets all application deployment objects for a specific collection and removes the deployments
Instead of this in the console : (on all deployment)

Run This :
Get-CMDeployment -CollectionName "Test - SCD" -FeatureType Application | Remove-CMDeployment -Force
Update-CMDistributionPoint – Use this cmdlet to update distribution points with the latest content
Instead of this in the console :

Run this :
Update-CMDistributionPoint -ApplicationName "7-zip 18.05" -DeploymentTypeName "7-zip 18.05"
Now that you know the basics, you can start writing some useful scripts to help you with your daily tasks. Get creative and automate the tasks you do the most often. SCCM Powershell cmdlet is not complicated to master, give you time and learn at your own pace. Leave your most used cmdlet in the comment section,
Please fill out the form, and one of our representatives will contact you in Less Than 24 Hours. We are open from Monday to Friday.
Thank you for subscribing to our newsletter or requesting a quote. You will receive our next month's newsletter. If you have requested a quote, we will get in touch with you as soon as possible.
Something went wrong!
Thank for your reply!