Last active
December 4, 2020 19:59
-
-
Save brianfgonzalez/93bd383a9473060d3b0fbb8b739f269c to your computer and use it in GitHub Desktop.
Iterates through an array of collection Ids and creates regional specific collections for each element.
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
$collectionIdList = @( | |
'SIH00021', | |
'SIH0001D', | |
'SIH00020', | |
'SIH00030', | |
'SIH00024', | |
'SIH0001F', | |
'SIH0002C', | |
'SIH0002B' | |
) | |
$regionList = @( | |
'America', | |
'Europe' | |
) | |
Import-Module "F:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1" -Verbose | |
Set-Location "sih:\" | |
foreach ($collectionId in $collectionIdList) | |
{ | |
Get-CMDeviceCollection -Id $collectionId -Verbose | ` | |
% { | |
$appCollectionName = $($_.name) | |
foreach ($region in $regionList) | |
{ | |
$newCollectionName = ('[{0}] {1}' -f $region, $appCollectionName) | |
if (! (Get-CMDeviceCollection -Name $newCollectionName) ) | |
{ | |
New-CMDeviceCollection ` | |
-Name $newCollectionName ` | |
-LimitingCollectionName ('[{0}]' -f $region) -Verbose | |
Add-CMDeviceCollectionIncludeMembershipRule ` | |
-CollectionName $appCollectionName ` | |
-IncludeCollectionName $newCollectionName -Verbose | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment