Hello,
You can use $var = [WMI] \\.\root\sms\site_xxx:SMS_Collection.CollectionID='ZZZ'
with xxx = sitecode and zzz=collectionID
That will return you an object with CollectionRules property that you don't have with a gwmi query.
BL
- Proposed as answer by Bartek Bielawski Wednesday, November 21, 2012 3:19 PM
Hello,
You can use $var = [WMI] \\.\root\sms\site_xxx:SMS_Collection.CollectionID='ZZZ'
with xxx = sitecode and zzz=collectionID
That will return you an object with CollectionRules property that you don't have with a gwmi query.
BL
- Proposed as answer by Bartek Bielawski Wednesday, November 21, 2012 3:19 PM
Hello,
You can use $var = [WMI] \\.\root\sms\site_xxx:SMS_Collection.CollectionID='ZZZ'
with xxx = sitecode and zzz=collectionID
That will return you an object with CollectionRules property that you don't have with a gwmi query.
BL
- Proposed as answer by Bartek Bielawski Wednesday, November 21, 2012 3:19 PM
In SCCM 2012, this data isn't immediately apparent:
But see what happens when using the expand switch:
Get-CMDeviceCollection | select -expand collectionrules
Another example below. This assumes Collections don't have multiple rules.
Get-CMDeviceCollection | ? {$_.CollectionRules.RuleName -ne $null} | % {Get-CMDeviceCollectionQueryMembershipRule -CollectionID $_.CollectionID -RuleName $_.CollectionRules.RuleName}
BTW, I found that in CU2 (maybe CU1) this issue seems to have been resolved. However CollectionRules seems to be case sensitive.
This works: Get-CMDeviceCollection | select -expand CollectionRules
This does not: Get-CMDeviceCollection | select -expand collectionrules
Hi,
I am trying to do the same thing and I can see how your script runs but I need a list either text or csv with the collection name or ID along with the corresponding queries. Do you know how to do this?
Thanks
A collection can have multiple query-based membership rules. Each of those rules can have multiple queries. CSVs are 2 dimensional, and don't support this type of nesting. You could simply take the first query from the first rule, but depending on how the collections are defined, there could be missing information.
XML on the other hand, can support this type of nesting.
I haven't tested this (use at your own risk), but this could be the general idea, if you wanted to move queries from one system to another, or simply back them up.
#Backup Collection Data from source computer Get-CMDeviceCollection | Export-Clixml 'c:\OldComputer\AllCollections.xml' #Restore to target computer (This sets the limiting collection to "All Systems" and also assumes there is only one membership rule) $allCollections = Import-Clixml 'c:\NewComputer\AllCollections.xml' $allCollections | ? {$_.isbuiltin -eq $false} | % { New-CMDeviceCollection -LimitingCollectionId SMS00001 -Name $_.Name Add-CMDeviceCollectionQueryMembershipRule -CollectionName $_.Name -RuleName $_.CollectionRules.RuleName -QueryExpression $_.CollectionRules.QueryExpression }
I had to fix the solution of the friend below a little and got almost what I want. Not full info coming out.
[WMI] '\\.\root\sms\site_EU1:SMS_Collection.CollectionID="EU100133"' | Format-table -Property CollectionRules
The result is as follows and ends with ...} thus not showing the whole ino!
CollectionRules
---------------
{EU-Workstations-PL0, EU-Workstations-DE0, EU-Workstations-DE1, EU-Workstations-PL1...}
Any other suggestion on how to get the full list in Collection Rules?