To use PowerShell with SCCM you will all you need to do is import the module. If you don’t have the module installed you can get it from here: https://www.microsoft.com/en-us/download/details.aspx?id=46681 Note that you will also need to have Configuration Manager Console installed on your computer.
Once you have the module installed, import the module using the following command:
import-module "C:\Program Files (x86)\Microsoft Configuration \Manager\AdminConsole\bin\ConfigurationManager.psd1"
Once you have imported the module you will need to connect to your site using the following:
Where ‘x’ is your site code. In my case this is:
Once connected to your site you can query information about your site using:
There are a whole bunch of cmdlets for SCCM that will allow you to do many tasks directly from the PowerShell console. I have a few SCCM scripts on my GitHub at: https://github.com/NathanKewley/Powershell_For_Dayz/tree/master/SCCM
As I create more scripts utilising SCCM I will be adding them to my Git. So far I have used PowerShell to query User and Device memberships from collections and export the results out to CSV’s for reporting.