Created
January 26, 2018 05:02
-
-
Save keithga/96aafefaa36573efced69cd0d1d20eb4 to your computer and use it in GitHub Desktop.
Add-CMDeviceCollectionDirectMembership Slow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
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