Connecting to SCCM using PowerShell
You can connect to an SCCM site server using PowerShell, but doing it without accessing the Configuration Manager Console on your computer is a bit tricky (remember, the point is to avoid GUIs). Again, the Microsoft documentation omits a crucial step.
To connect using the PowerShell module for SCCM successfully, do the following from the computer that has the Configuration Manager Console installed:
- Right-click the Windows PowerShell icon and choose "Run as administrator".
CD 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin'and hit enter.
Import-Module .\ConfigurationManager.psd1and run it.
- Here's the crucial missing step. Enter
New-PSDrive -Name [yoursitecode] -PSProvider "AdminUI.PS.Provider\CMSite" -Root "[your SCCM server's FQDN]" -Description "SCCM Site"
- Now we can connect to the site. Enter
CD ABC:, where
ABCis your site code. The colon is necessary!
Now you should be all set to begin running SCCM cmdlets.