System Center Configuration Manager (SCCM) is an competent tool for managing many computers and servers. One of the best ways of communication with SCCM is by PowerShell if you want to do things such as change site codes. In this blog post, we will discuss connecting to SCCM via PowerShell ISE and remotely, along with the steps indispensable to change the site code successfully.
Connecting to SCCM Capitalizing on PowerShell ISE
Connecting to the SCCM environment is the first step to do when you want to control SCCM with PowerShell. PowerShell Integrated Scripting Environment (ISE) is a well-known graphical interface application for PowerShell users to run commands and scripts.

Steps to Connect to SCCM via PowerShell ISE
- Launch PowerShell ISE: Type “PowerShell ISE” into the Windows search bar and click on it to start.
- SCCM Module Import: Unless you have imported the SCCM PowerShell module you deny be able to run any commands. As a consequence, the following command below should be iss powershellCopy codeImport-Module (Join-Pathway (Get-PSDrive -PSProvider FileSystem).Root ‘Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationM
- Connect to the SCCM Site: This is the command you use to connect to your site. You should substitute your site code with the actual site code. CD YourSiteCode: saidnerLeggacher1:
Now you’re linked with SCCM and on the go to issue commands!
Connecting to SCCM PowerShell Remotely
Sometimes, you may have to deal with SCCM from a different computer. Here is the method I used for connecting to SCCM PowerShell remotely.

Steps for Remote Connection
- Equip PowerShell Remoting: Validate that PowerShell remoting is enabled on your PC and server. To do so, run the following: powershellCopy codeEnable-PSRemoting -Force.
- Establish a Remote Session: Use the below-stated command to launch a remote session. Then, replaceYourSCCMServerwith the name of your SCCM server.PowerShellCopy code$session = New-PSSession -ComputerName YourSCCMServer
- Import the Session: Import the session in order to initiate SCCM commands remotely: PowerShellCopy CodeInvoke-Command -Session $session -ScriptBlock { Import-Module (Join-Way 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1') }
- Connect to Your Site Code:powershellCopy codeInvoke-Command -Session $session -ScriptBlock { CD YourSiteCode: }
Now if you have got SCCM, you are now ready to administer it remotely!
Changing Site Code in SCCM with PowerShell
Altering the site code might be a much-mandatory action while restructuring your entire system. You can do it by applying PowerShell. Below are the steps to take.

Steps to Change Site Code
- Get the Current Site Code: First collect the current site configuration and perform the powershell code given below:copy codeGet-WmiObject -Namespace Root\SMS -Class SMS_ProviderLocation | Select-Object SiteCode
- Change the Site Code: Just follow the below-mentioned command to change the site code. Replacethe NewSiteCode parameter with the code you want to use: powershellCopy codeSet-CMServer -SiteCode NewSiteCode
- Verify the Change: The developments were made successfully indeed! Try requesting the site code via the following command to see if it differs from the previous one:powershellCopy codeGet-WmiObject -Namespace Root\SMS -Class SMS_ProviderLocation | Select-Object SiteCode
Resolution
The use of PowerShell for SCCM administration not only saves time but also adds to the capability of the process. When connected to SCCM through PowerShell ISE or remotely, you can fulfill commands to change the site codes and perform other administrative tasks from one location. Whether or not you are an experienced SCCM admin or a beginner, over time, it would be a very potent resource to know how to use PowerShell to do tasks skillfully and easily when managing SCCM.