Add-CMDeviceCollectionDirectMembership Slow
<# | |
Example of how to create a Device Collection and populate it with computer objects | |
The Slow way. <Yuck> | |
#> | |
[cmdletbinding()] | |
param( | |
$CollBaseName = 'MyTestCol_03_{0:D4}', | |
$name = 'PCTest*' | |
) | |
foreach ( $Count in 5,50 ) { | |
$CollName = $CollBaseName -f $Count | |
write-verbose "Create a collection called '$CollName'" | |
New-CMDeviceCollection -LimitingCollectionName 'All Systems' -Name $CollName | % name | write-Host | |
Measure-Command { | |
Write-Verbose "Find all Devices that match [$Name], grab only the first $Count, and add to Collection [$CollName]" | |
get-cmdevice -name $name -Fast | | |
Select-Object -first $count | | |
Foreach-Object { | |
Add-CMDeviceCollectionDirectMembershipRule -CollectionName $CollName -ResourceId $_.ResourceID -verbose:$False | |
} | |
} | % TotalSeconds | write-Host | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment