SCCM : Client Site Code Change

SCCM : Client Site Code Change

I had a need recently to change the site code of some SCCM cliwents that had already been deployed. I used the following vbScript to change the site code of a client (remotely or locally!), the script can be integrated into a logon script to automate the process if desired:

vbScript

View source
  1. 'Replace NEW_SITE with your Site Code
  2. sSiteCode = "NEW_SITE"
  3. sMachine = "."
  4. set oCCMNamespace = GetObject("winmgmts://" & sMachine & "/root/ccm")
  5. Set oInstance = oCCMNamespace.Get("SMS_Client")
  6. set oParams = oInstance.Methods_("SetAssignedSite").inParameters.SpawnInstance_()
  7. oParams.sSiteCode = sSiteCode
  8. oCCMNamespace.ExecMethod "SMS_Client", "SetAssignedSite", oParams