Changing a Site Name in ConfigMgr 2012 via PowerShell

PrimSiteNameAlready a few years ago, I did a small post about Renaming your ConfigMgr Primary Site. Even though it was not a supported action, as it meant directly editing the site control file, it was sometimes necessary. Since the release of ConfigMgr 2012, I’ve had many questions if that post is still applicable. The answer on that simple, it’s not applicable for ConfigMgr 2012, as it doesn’t use the sitectrl.ct0 file in that form anymore.

So, does this mean that we can’t change the site name anymore? Well, the answer on that is also, no. Of course we can still change it! The only thing to keep in mind is that we’re moving into a grey area, of what’s supported, and what’s not.

PowerShell and WMI

As in my recent posts, we can find our help in PowerShell and WMI. There only thing we need to know is where can we find an editable property for the current site name. That property can be found in the SMS_SCI_SiteDefinition class in WMI. Now the script is “easy” to create and complete, as it only needs three things:

  1. Create an object of the SiteDefinition that we want to change.
  2. Change the property SiteName to our new name.
  3. Save the changes.

This gives us the following small script (really, this is all!).

###################################################################################################
# Project: Change Site Name
# Date: 20-05-2013
# By: Peter van der Woude
# Version: 1.0 Public
###################################################################################################

[CmdletBinding()]

param (
[string]$SiteCode,
[string]$SiteServer,
[string]$SiteName
)

function Change-SiteName {
    $Site = Get-WmiObject -Class SMS_SCI_SiteDefinition -Namespace root/SMS/site_$($SiteCode) -ComputerName $SiteServer | Where-Object -FilterScript {$_.SiteCode -eq $SiteCode}
    $Site.SiteName = $SiteName
    $Site.Put()
}

Change-SiteName

Either copy the code, or download it via the TechNet Galleries. This script needs a few parameters, of which the SiteCode is the most important. That parameter will be used for a WMI connection and for determining the of which site the name has to be changed.

Example: PowerShell.exe -ExecutionPolicy ByPass .\ChangeSiteName_v1_0.ps1 -SiteCode <SiteCode> -SiteServer <SiteServer> -SiteName <SiteName>

Conclusion

It is quite simple to change the site name. To check the results close the Configuration Manager Console and start it again (or check it in WMI). Keep in mind that this is editing site control information, which can break a site when it’s not done properly! Make sure to test this script before usage and use at own risk!

See for more information: http://msdn.microsoft.com/en-us/library/jj885703.aspx

9 thoughts on “Changing a Site Name in ConfigMgr 2012 via PowerShell

  1. Hi Peter,

    Just wondering if there’s a way to change the server site name of the primary site such as server1.corp.com to prod1.corp.com and database site (site system server) such as server2.corp.com to db.corp.com.

    Many thanks

Leave a Comment