Tuesday, February 21, 2017

Powershell - Remove all included collections from a given collection ID

# Remove all included collections from a given collection ID
# Code Segment by Mark Randol - randoltech.blogspot.com
$ArrIncludeRules = Get-CMCollectionIncludeMembershipRule -CollectionId $DeploymentCollectionID
[Int]$LoopCounter = -1
foreach ($IncludeRule in $ArrIncludeRules)
{
    $LoopCounter++
    $IncCollID = $ArrIncludeRules.IncludeCollectionID[$LoopCounter]
    Write-Output "Removing $IncCollID"
    Remove-CMDeviceCollectionIncludeMembershipRule -CollectionId $DeploymentCollectionID -IncludeCollectionId $IncCollID -Force
}

No comments:

Post a Comment