Add AD group to collection w/powershell

miguel rodriguez 41 Reputation points
2020-09-17T13:46:28.087+00:00

trying to add an ad group as collection member
is there any cmdlet i can use?
get-cmuser only retrieves User objects not groups...

Microsoft Configuration Manager
0 comments No comments
{count} votes

Accepted answer
  1. Jason Sandys 31,186 Reputation points Microsoft Employee
    2020-09-17T21:50:04.81+00:00

    Depending on exactly what your end goal is, you can use either Add-CMDeviceCollectionDirectMembershipRule or Add-CMUserCollectionQueryMembershipRule.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. AllenLiu-MSFT 42,031 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.

    0 comments No comments

  2. 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.

    0 comments No comments