How to Connect to SCCM using PowerShell

In this post, you’ll learn how to connect to SCCM using PowerShell from the console which allows running cmdlets. Connecting to Configuration Manager using PowerShell lets you run cmdlets and scripts.

Starting in ConfigMgr version 2111, the path to the module is now added to the system environment variable, PSModulePath when you install ConfigMgr console. Once you have established a PS session with SCCM, you can run PowerShell scripts to automate or extend Configuration Manager.

Thanks to Microsoft, Configuration Manager lets you use the Windows PowerShell to manage your hierarchy including objects such as devices, users and other components. When you run Configuration Manager cmdlets by using the Configuration Manager console, your session automatically runs in the context of the site.

The Configuration Manager PowerShell module requires Microsoft .NET version 4.7.2 or later before using it. Ensure you update the dot net framework on SCCM server to 4.7.2 before running ConfigMgr PowerShell cmdlets.

How to Connect to SCCM using PowerShell

Perform the following steps to connect to SCCM using PowerShell from ConfigMgr console:

  • Launch the Configuration Manager console.
  • In the upper-left corner, there’s a blue rectangle. Select the white arrow in the blue rectangle, and choose Connect via Windows PowerShell.
How to Connect to SCCM using PowerShell
How to Connect to SCCM using PowerShell
  • Once you have established PS session with SCCM, you’ll see the site code which confirms that you can now run Configuration Manager cmdlets.
How to Connect to SCCM using PowerShell
How to Connect to SCCM using PowerShell

What you can do next is run the Get-CMSite cmdlet. This cmdlet returns information about the Configuration Manager site you’re currently connected to and any child sites. For example, the site server name, installation director, site name, and version. You can get a Configuration Manager site by using either a site name or a site code.

Source
Prajwal Desai

Pragati

Hi, I am Pragati. As a Technical Consultant, I help businesses harness the latest innovations in Cloud applications, Intune, Windows 365, and more. Sharing my knowledge and insights through this blog to inspire and empower others in their digital transformation. Let's revolutionize the way we work and thrive in the cloud era together!

Related Articles

Back to top button