Change SCCM 2012 Site Name/Description

No Gravatar

Changing the site name or description in SCCM is frankly a pain in the rear.  To my knowledge SCCM doesn’t use it internally and it is simply a description for the administrators to identify some characteristics about the site.  This is really only needed because the Site Code is limited to 3 characters… still.  </end rant>

I have a System Center 2012 Configuration Manager Secondary Site server and need to change it’s name/description.  In SCCM 2007 this could be done by editing the Site Control File which is unsupported by Microsoft.  SCCM 2012 doesn’t use the same type of Site Control file, it is an XML embedded in SQL.

Rikard Rönnkvist has a simple SQL statement for changing the Site name/description here: http://www.snowland.se/2012/10/12/update-configmgr-site-description

Anoop C. Nair does some interesting investigation with the embedded Site Control file here: http://anoopcnair.com/2012/05/23/configmgr-sccm-2012-how-to-edit-site-control-sitectrl-file

But I really didn’t want to hack the database.  I went looking for a WMI method and found Peter van der Woude’s PowerShell script to change a Primary Site name/description here: http://www.petervanderwoude.nl/post/changing-a-site-name-in-configmgr-2012-via-powershell

I’m still pretty new to PowerShell, but after poking at it a bit I was able to modify it to change the name/description of a Secondary Site.  Here’s the end result.  95% of the credit goes to Peter.  Thanks, Peter!

Save this code as a ChangeSiteName_v1.1_ps1

[cc lang=’powershell’ ]

[CmdletBinding()]

param (
[string]$PrimarySiteCode,
[string]$PrimarySiteServer,
[string]$SiteCodeOfSiteToChange,
[string]$NewSiteName
)

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

Change-SiteName

[/cc]

Now run it.  It should work remotely, but I ran it from the Primary Site Server.

[cc lang=’powershell’ line_numbers=’false’]

PowerShell.exe -Execution Policy ByPass .\ChangeSiteName_v1.1_ps1 -PrimarySiteCode “PrimarySiteCode>” -PrimarySiteServer “PrimarySiteServer” -SiteCodeOfSiteToChange “MySiteCode” -NewSiteName “MyNewSiteName”

[/cc]

 

September 13, 2013

Posted In: ConfigMgr 2012, Scripting