If you want to run scripts in Powershell for managing your SCCM environment, you will find that they are not available by default on your client.
This blog post covers how to import the Configuration Manager module for Powershell.
What is the Powershell module in SCCM (MEMCM)
The Powershell module for SCCM contains many CMDlets, which lets you manage your environment through Powershell.
If you wish to create scripts to automate your daily tasks, the Powershell CMDlets is a must.
How to import the SCCM (MEMCM) Powershell module
To use the Powershell CMDlets, you need to import the Configuration Manager Powershell module.
Import-Module (Join-Path $(Split-Path $env:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1)
You can also browse to the SCCM installation directory, which by default is C:\Program Files (x86)\Microsoft Endpoint Manager\AdminConsole\bin
Enter the below command:
How to run cmdlets from the SCCM Powershell module
Once you have imported the module in Powershell, you will need to set the location to the Powershell drive of the MEMCM (SCCM) site server. This is the site code of the primary site.
The easiest way to do this is by running the below commands, either manually or in a script:
$SiteCode = Get-PSDrive -PSProvider CMSITE Set-Location -Path "$($SiteCode.Name):\"
How to start Powershell from the SCCM Console
Another alternative that you can use is to run Powershell from the Configuration Manager console.
Press the down arrow and Connect via Windows Powershell.
Once the Powershell window is open, it will automatically set the location to the MEMCM (SCCM) site.
Using Powershell to manage MEMCM (SCCM) is a must in most cases. When doing anything in bulk, it is simply not possible to use the console.
I hope this blog post was informative to you. Please leave any suggestions for improvements in the comments section.
- Pluralsight – Administering SCCM Current Branch and Intune integration
- Get started with ConfigMgr cmdlets