Depending on exactly what your end goal is, you can use either Add-CMDeviceCollectionDirectMembershipRule or Add-CMUserCollectionQueryMembershipRule.
Add AD group to collection w/powershell
trying to add an ad group as collection member
is there any cmdlet i can use?
get-cmuser only retrieves User objects not groups...
-
Jason Sandys 31,311 Reputation points Microsoft Employee
2020-09-17T21:50:04.81+00:00
2 additional answers
Sort by: Most helpful
-
AllenLiu-MSFT 45,606 Reputation points Microsoft Vendor
2020-09-18T05:09:12.673+00:00 @miguel rodriguez
Thank you for posting in Microsoft Q&A forum.
It looks like you want to create a user collection based on an AD user group, you may try the cmdlet to add a query rule for your collection:Add-CMUserCollectionQueryMembershipRule -CollectionName "xxxxx" -QueryExpression "select * from SMS_R_User where SMS_R_User.SecurityGroupName ='xxxxxxx'" -RuleName "xxxxx"
Note: Make sure you have enabled and completed the AD Group Discovery
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. -
miguel rodriguez 41 Reputation points
2020-09-18T08:40:54.6+00:00 was thinking in the wrong direction here.
Thx for clarifying.
A query rule did the job.