Already 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:
- Create an object of the SiteDefinition that we want to change.
- Change the property SiteName to our new name.
- 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
Hey Peter,
great job! I’ve add your website to my blog-recommendations on my blog.
Greatz from germany!
André
Thanks André!
This was incredibly helpful, Peter.
I’ve modified the script to affect Secondary Sites @ http://chadstech.net/sccm-2012-site-name-change
Hi Peter,
Thanks for this great script. This helped me fix a nasty spelling error in my environment.
Grtz,
Marc
can we use this code to change site database name?
You should not use this to change the site database name. To change that name you can perform site maintenance.
Can I use this script to change the site code?
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
No, you should not adjust the name of the site server.
Great Infos !
Thank you
Thank you. I too had a nasty spelling mistake in the display name of the Primary site server. I’m much happier now!
Great to hear Paul!