Friday, October 9, 2015

Create Boundary Group and Boundary Powershell Script

Below is the powershell script that I created my latest project. So this is how the script works:
  1. Create Boundary Group
  2. Add Site Server to Boundary Group (You’ll need to install all your distribution point first!)
  3. Create AD Site boundary and add to Boundary Group accordingly to the boundary.csv
Import-Module "D:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"

#SCCM Site Code
cd L28:

#Define all your boundary group name here:
New-CMBoundaryGroup -Name "Kuala Lumpur"
New-CMBoundaryGroup -Name "Penang"
New-CMBoundaryGroup -Name "Johor"
New-CMBoundaryGroup -Name "Sabah"
New-CMBoundaryGroup -Name "Sarawak"

#Define the boundary group site server:
Set-CMDistributionPoint -sitecode L28 -SiteSystemServerName KULDP001.domain.com -AddBoundaryGroupName "Kuala Lumpur"
Set-CMDistributionPoint -sitecode L28 -SiteSystemServerName PNGDP001.domain.com -AddBoundaryGroupName "Penang"
Set-CMDistributionPoint -sitecode L28 -SiteSystemServerName JHRDP001.domain.com -AddBoundaryGroupName "Johor"
Set-CMDistributionPoint -sitecode L28 -SiteSystemServerName SBHDP001.domain.com -AddBoundaryGroupName "Sabah"
Set-CMDistributionPoint -sitecode L28 -SiteSystemServerName SRWDP001.domain.com -AddBoundaryGroupName "Sarawak"

Import-Csv D:\Scripts\Boundary\Boundary.csv |
ForEach-Object
{
New-CMBoundary -Name $_.Description -Type ADSite -Value $_.ADSiteName
Add-CMBoundaryToGroup -BoundaryName $_.Description -BoundaryGroupName $_.BoundaryGroup
}

The boundary.csv format is as below:
Description,ADSiteName,BoundaryGroup
1U,1U,Kuala Lumpur
AU2,AU2,Kuala Lumpur
BKT,BKT,Kuala Lumpur
KB,KB,Kuala Lumpur
KK,KK,Kuala Lumpur
KTN,KTN,Kuala Lumpur
KUC,KUC,Kuala Lumpur
Lot28,Lot28,Kuala Lumpur
MLK,MLK,Kuala Lumpur
SBN,SBN,Kuala Lumpur
SWY,SWY,Kuala Lumpur
TPC,TPC,Kuala Lumpur
PNG,PNG,Penang
JHR,JHR,Johor
SBH,SBH,Sabah
SRW,SRW,Sarawak

Regards,
Hau





10 comments: