counter customizable

PowerShell – Import Configuration Manager module

Here is a script to import the Configuration Manager module in PowerShell. The module will only be imported in not previously imported.


# Import the module
if (-not (Get-Module ConfigurationManager))
Write-Host “Configuration Manager not loaded, loading…”
import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + ‘\ConfigurationManager.psd1’)
$PSD = Get-PSDrive -PSProvider CMSite
$SiteCode = $PSD.Name
CD “$($PSD):”
ELSE {Write-Host “Configuration Manager Already Loaded”}


This will not work if you have more then one Site Code in Active Directory, then you need to specify witch Site Code.

Mikael Karlsson posted at 2015-10-13 Category: Configuration Manager 2012, PowerShell