Adding computer objects from OU to multiple security groups

Welcome Forums General PowerShell Q&A Adding computer objects from OU to multiple security groups

This topic contains 5 replies, has 2 voices, and was last updated by

 
Participant
1 month, 2 weeks ago.

  • Author
    Posts
  • #169180

    Participant
    Topics: 1
    Replies: 2
    Points: 16
    Rank: Member

    I need to get computer objects from particular AD OU and import them into multiple (two) security groups. This of course works for a single security group, but not sure how to do multiple groups.

     

    $Comps = Get-ADcomputer -SearchBase 'ou=test ,ou=all computers,dc=name1,dc=name2,dc=com' -filter *
    add-adgroupmember -identity 'SecGroup' -members $Comps
  • #169190

    Participant
    Topics: 1
    Replies: 1529
    Points: 2,587
    Helping Hand
    Rank: Community Hero

    Did you try to search for it? There are literally thousands of examples all over the internet and probrably even hundreds here in this forum. Take a look at the cmdlet Add-ADPrincipalGroupMembership and read the complete help including the examples, please.

  • #169201

    Participant
    Topics: 1
    Replies: 2
    Points: 16
    Rank: Member

    I have searched. Everything I find is for adding the systems in an OU to one group not multiple groups. I am willing to accept that I can't find the answer at this point and this is the reason I posted the question here. Either way I will keep looking. Thank you for your reply.

  • #169228

    Participant
    Topics: 1
    Replies: 1529
    Points: 2,587
    Helping Hand
    Rank: Community Hero

    Did you read the help in the link I posted?

  • #169258

    Participant
    Topics: 1
    Replies: 2
    Points: 16
    Rank: Member

    Yes I got it now. Took me a minute. I think I was confused on the difference between add-adprincipalgroupmembership vs add-adgroupmember. Thank you again for your help.

  • #169264

    Participant
    Topics: 1
    Replies: 1529
    Points: 2,587
    Helping Hand
    Rank: Community Hero

    I'm glad it helped. 😉 If you need more help – come back.

You must be logged in to reply to this topic.