MEMCM - Create Boundary & Collection
### IP Range ###
$Region = "East"
$3Digit = "MAR"
$SiteName = "Marion"
$IPRange = "10.10.10."
$IPRangeENDX = "x"
$IPRangeENDVari = "%"
$IPRangeBegin = "1"
$IPRangeEnd = "254"
$BoundaryName = "$Region | $3Digit | $SiteName | $IPRange$IPRangeENDX"
$IPStartEnd = "$IPRange$IPRangeBegin-$IPRange$IPRangeEnd"
$QueryName = "IPV Range | $IPRange$IPRangeENDX"
## Name of collection
$Collection = "$Region | $3Digit | IPV4 Range | $IPRange$IPRangeENDX"
## Limiting collection
$LimitingColl = "All Systems"
## Folder for Device collection #### IPV\East # IPV\Midwest # IPV\West ######
$DCFolder = "Sites by IPV\$Region"
## Creates collection
New-CMCollection -CollectionType Device -LimitingCollectionName $LimitingColl -Name $Collection
# Move New Collection to Folder
$CMCollection = Get-CMDeviceCollection -Name $Collection
Move-CMObject -FolderPath "SF3:\DeviceCollection\$DCFolder" -InputObject $CMCollection
##### Add query for IP range
$wql = "select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.IPSubnets like `"$IPRange$IPRangeENDVari`""
Add-CMDeviceCollectionQueryMembershipRule -CollectionName $Collection -QueryExpression $wql -RuleName $QueryName
New-CMBoundary -DisplayName $BoundaryName -BoundaryType IPRange -Value $IPStartEnd
$Collection
$BoundaryName
Last updated
Was this helpful?