Microsoft Endpoint Configuration Manager (SCCM/MECM) management through Powershell

Microsoft Endpoint Configuration Manager can be managed through Powershell scripts or cmdlets.

The first thing we need to do is to open the access we choose from the SCCM Console, in our Site Server:

  • Connect via Powershell (Cmdlets)
  • Connect via Powershell ISE (Scripts & Cmdlets)

I choose using only cmdlets. We are now connected directly to our current site server, the drive corresponds to our site code (PGD:).

We can get additional information about the module, through its methods in order to import the module later from Powershell console or scripting it.

We import the module from command prompt.

powershell
cd /d "e:\Microsoft Configuration Manager\AdminConsole\bin"
Import-Module .\ConfigurationManager.psd1

We list the available drives, searching our SCCM Site.

Get-PSDrive
cd PGD:

We can create additional drive names to make them more readable using the same provider.

New-PSDrive `
  -Name "PGD_HA01" `
  -PSProvider "AdminUI.PS\CMSite" `
  -Root "SCCMHAPS01.pagodait.local" `
  -Description "SCCM PGD - High Availability - PS01"

New-PSDrive `
  -Name "PGD_HA02" `
  -PSProvider "AdminUI.PS\CMSite" `
  -Root "SCCMHAPS02.pagodait.local" `
  -Description "SCCM PGD - High Availability - PS02"

New-PSDrive `
  -Name "PGD_DP01" `
  -PSProvider "AdminUI.PS\CMSite" `
  -Root "SCCMDP01.pagodait.local" `
  -Description "SCCM PGD - Distribution point - 01"

New-PSDrive `
  -Name "PGD_DP02" `
  -PSProvider "AdminUI.PS\CMSite" `
  -Root "SCCMDP02.pagodait.local" `
  -Description "SCCM PGD - Distribution point - 02"

Note: We’ll need to set the location into each of these drives to be able to run cmdlets on any of the servers.

Finally, we can list all the commands in this module.

(Get-Command -Module ConfigurationManager -Type Cmdlet).count
1040
Get-Command -Module ConfigurationManager -Type Cmdlet | Sort Name | More

Links:

https://docs.microsoft.com/en-us/powershell/module/configurationmanager/?view=sccm-ps