Friday, June 5, 2015

ConfigMgr 2012 Site Boundary Group Assigmentment

If you have a 2007 and 2012 SCCM site you can't use site assignment because the 2012 machines might try to assign themselves to the 2007 site.  It can be confusing enough to have both infrastructures.  Or maybe you didn't set it before for some reason.  If you have too many to do by hand then here is a script you can modify to use in your enviroment. 

Recall that you cannot assign a boundary group to a Secondary Site code, it must be assigned to the Primary.  Yes, I realize it is in the drop down list because it is a site but you should always assign the site to the Primary just like the client would see in the Site settings.

We have our Boundary Group labled as such:


Location - SiteCode
London1 - SC2
London2 - SC2
Scotland - SC3
Texas - SC1
Washington - SC4

The reason for this is to quickly determine where a bound group is connected in terms of the secondary controlling it.  For this reason we need to look at the Secondary site code and associate it with the Primary.


##PowerShell set the primary for the group.
$SiteServer = "foo.com"
$SiteCode = "PR1"
$WMIConnection = [WMICLASS]"\\$SiteServer\Root\SMS\Site_$($SiteCode):SMS_BoundaryGroup
$BoundaryLIst = $WMIConnection.psbase.GetInstances()
foreach ($Boundary in $BoundaryLIst)
{
    #echo $Boundary.Name
     $SecondarySiteCode = $Boundary.Name.Substring($Boundary.Name.Length-3,3)
     $Primary="CHECK"
    Switch ($SecondarySiteCode)
   {
   SC1 { $Primary="PR1"}
   SC2 { $Primary="PR2"}
   SC3 { $Primary="PR2"}
   SC4 { $Primary="PR1"}
   SC5 { $Primary="PR1"}
   SC5 { $Primary="PR3"}
 
   }

 if ($Primary -eq "CHECK")
 {
   echo $Boundary.Name
 }
 else
 {
  ##boundary group is correct set it
  $Boundary.DefaultSiteCode = $Primary
  $Boundary.Put()
  }
}
################################################

Note that if you want to uncheck the box you can simply blank the DefaultSiteCode
$Boundary.DefaultSiteCode = ""