Change Site Code of Configuration Manager Client

In this short post we will see how to change site code of Configuration Manager client. Every site has a site server, a site database, and a three-character alphanumeric site code. The site code must be unique in the hierarchy.

Site codes are used to identify the sites in a Configuration Manager and site code must uniquely identify each Configuration Manager site in the hierarchy. Having said that there might be reasons why you want to change the site code of the configuration manager client.

Let’s assume you have ConfigMgr 2007 installed in your company and now you want to migrate the objects to Configuration manager 2012. ConfigMgr 2007 and SCCM 2012 publish information into the same Active Directory system folder when implemented in the same domain. As a part of the migration process, you should plan for new site codes for your System Center 2012 Configuration Manager hierarchy.

Configuration Manager Client Site Code

When you are choosing the site code while installing SCCM you should keep few things in mind.

1) Avoid using reserved names such as AUX, CON, NUL, PRN when choosing site codes. Click this link to see list of reserved file names.

2) Avoid reusing site codes previously used in your ConfigMgr hierarchy. Configuration Manager Setup does not verify that the site code entered is not already in use. Site codes are stored in the site databases.

Change Site Code of Configuration Manager Client

Now we will see how to change site code of SCCM client using a script. In the below script replace your site code in place of P01 and save it as filename.vbs. The script can be downloaded here.

On Error Resume Next
set oSMSClient = CreateObject ("Microsoft.SMS.Client")
'if Err.Number <>0 then
'wscript.echo "Could not create SMS Client Object - quitting"
'end if
'Assign client to Servername
oSMSClient.SetAssignedSite "P01",0
set oSMSClient=nothing

If you want to change the site code on a single computer then copy the script to the computer and run the script. If you are looking to change the site code for set of computers then let’s see how to do that.

Launch the configuration manager console, navigate to Software Library > Packages. Right Packages and click Create Package.

Change Site Code of Configuration Manager Client

Specify the Name and Source folder of the package. Click Next.

Change Site Code of Configuration Manager ClientCreate a standard program and specify the details such Name, command line etc. Click Next.

Change Site Code of Configuration Manager Client

Complete the rest of the steps and click Close.

Change Site Code of Configuration Manager Client

Deploy Change Site Code Script

After you create this package you need to distribute the package to the DP. Once the package is available with the distribution point, right the package and click Deploy.  Select the collection and click Next.

Change Site Code of Configuration Manager Client

Choose the purpose as Required or Available. Click Next.

Change Site Code of Configuration Manager Client

To schedule the deployment click on New and click As soon as possible. Click Next.

Change Site Code of Configuration Manager Client

Complete the remaining steps and click Close.

Completion step

After few minutes login to the client computer and check the configuration manager properties. Click General tab and under client properties we see that the site code is changed to P01 (as per the script).

Client Properties

For troubleshooting purpose you can view the execmgr.log file.

execmgr.log file

Related Posts
Oldest Most Voted
Inline Feedbacks
View all comments
chekuri sandeep

Hi Prajwal,

I need a powershell script to check whether the client site code is correct or not (client machines are communicating with the correct primary site code or not) as i am very new to the powershell script, please get me a script on which i have asked and do the needful.


Hi Sir,
I have site server A and site server B,in site A i have 3 forest domain, i have moved one domain to Site Server B. i have done discover and publishing now i can see the client in Site B,Is it possible to change the SITE code through SCCM or i need to create a group policy for this, please tell me any other way


Hi sir,

Recently migrating server sccm 1806 but site code I used your script it’s worked manual but situation now my workstation not communicate with server but I need to deploy on all machine after run script need to do manual discover then I can get site code properly. So how can I discovered site by automation.. please suggest

Akhilesh Gupta

Hi Prajwal,

This script does nothing to me, below is the message I get in execmgr.log file

CServiceWindowsEventHandler::Execute – Received SERVICEWINDOWEVENT : END EVENT
Service startup.
A user has logged on.
The logged on user is XXXX

That’s it. Appreciate your help here.


I get the same error but it might have to do with the fact that I have an assigned management point. Do I need to uninstall the Management Point Role in order to get this fixed? Also Co-management Capabilities and Co-management are set to 1 and DISABLED respectively. I see in the example these configurations are not there. Does this mean that I need to change any of these?

Last edited 28 days ago by Jordan


after changing the sitecode, i am unable to launch software center. i am running sccm 2016 1710


you actually need to change SMSSLP in the registry too. Under HKLM\Software\Microsoft\CCM


Must be 2012.. his screenshots are of 2012, and his scenario was migrating from 2007 to 2012. What i don’t get is how do you already have a Windows 7 collection in the new site? Those machines must have been discovered first right? And if so, wouldn’t they already have the client installed, pointing them to the new site code?

Leonardo Ramirez

Change Site Code of Configuration Manager Client,
Hi, This process of deployment I am doing it in the old SCCM Server or in the new SCCM Server

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More