To create a Boundary Group
- Set up a connection to the SMS Provider.
- Create an instance of the SMS_BoundaryGroup WMI class
- Set the Name property.
- Depending on the configuration, set the correct values
Examples
#Example 1
$Arguments = @{Name = "New Boundary Group"}
Set-WmiInstance -Namespace "Root\SMS\Site_PR1" -Class SMS_BoundaryGroup -Arguments $Arguments
|
#Example 2
$Arguments = @{Name = "New Boundary Group"}
Set-WmiInstance -Namespace "Root\SMS\Site_PR1" -Class SMS_BoundaryGroup -Arguments $Arguments -ComputerName Server
|
#Example 3
$Arguments = @{Name = "New Boundary Group"}
Try{
Set-WmiInstance -Namespace "Root\SMS\Site_PR1" -Class SMS_BoundaryGroup -Arguments $Arguments -ComputerName Server -ErrorAction STOP
}
Catch{
$_.Exception.Message
}
|
#Example 4
$WMIConnection = [WMICLASS]"\\Server\ROOT\SMS\Site_PR1:SMS_BoundaryGroup"
$NewBoundaryGroup = $WMIConnection.psbase.CreateInstance()
$NewBoundaryGroup.Name = "New Boundary Group"
$NewBoundaryGroup.Put()
|
#Example 5
Function New-BoundaryGroup
{
[CmdLetBinding()]
PARAM(
[Parameter(Mandatory = $True, HelpMessage = "Please enter site server name")]
$SiteServer,
[Parameter(Mandatory = $True, HelpMessage = "Please enter site server code")]
$SiteCode,
[Parameter(Mandatory = $True, HelpMessage = "Please enter Boundary Group name")]
$Name
)
$Arguments = @{Name = $Name}
Try{
Set-WmiInstance -Namespace "Root\SMS\Site_$SiteCode" -Class SMS_BoundaryGroup -Arguments $Arguments `
-ComputerName $SiteServer -ErrorAction STOP
}
Catch{
$_.Exception.Message
}
}
New-BoundaryGroup -SiteCode PR1 -SiteServer Server -Name "New Boundary Group"
|
Example Output

You can download the code examples from here
20
JUN
Share