#Give the Ad group names in the CSV file
$Collections = Import-Csv -Path "C:\SCCM_Scripts\adgroupcollectionslists.csv"
foreach ($col in $collections )
{
$Schedule = New-CMSchedule -Start "01/01/2019 12:00 AM" -DurationInterval Minutes -DurationCount 0 -IsUtc:$False -Nonrecurring
$col.Name
$query = "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.SystemGroupName = 'Domain\\$($col.Name)'"
#Change the domain name in the above line
New-CMDeviceCollection -Name $col.Name -LimitingCollectionId 'SMS00001' -RefreshType None -RefreshSchedule $Schedule | Out-Null
Add-CMDeviceCollectionQueryMembershipRule -CollectionName $col.Name -QueryExpression $query -RuleName $col.Name
}
$Collections = Import-Csv -Path "C:\SCCM_Scripts\adgroupcollectionslists.csv"
foreach ($col in $collections )
{
$Schedule = New-CMSchedule -Start "01/01/2019 12:00 AM" -DurationInterval Minutes -DurationCount 0 -IsUtc:$False -Nonrecurring
$col.Name
$query = "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.SystemGroupName = 'Domain\\$($col.Name)'"
#Change the domain name in the above line
New-CMDeviceCollection -Name $col.Name -LimitingCollectionId 'SMS00001' -RefreshType None -RefreshSchedule $Schedule | Out-Null
Add-CMDeviceCollectionQueryMembershipRule -CollectionName $col.Name -QueryExpression $query -RuleName $col.Name
}
No comments:
Post a Comment