How to add or remove Entire Directory users from any group in Active Directory

This topic contains 2 replies, has 3 voices, and was last updated by Profile photo of Simeon Iksanov Simeon Iksanov 1 year, 5 months ago.

  • Author
    Posts
  • #28690
    Profile photo of Avinash Jaiswal
    Avinash Jaiswal
    Participant

    How to add or remove Entire Directory users from any group in Active Directory powershell.
    I am creating script to Add or remove user in AD groups.
    My script is working for same domain. but If user is exist in another domain or forest, i am not able to perform action onto that.
    Please help me on this.

  • #28693
    Profile photo of Matt Bloomfield
    Matt Bloomfield
    Participant

    When working with group members from another domain, or when working with groups in another domain, you need to fetch the user object or group first. There is an MSDN article that explains why and has some example code:

    Adding Removing Members from Another Forest or Domain

  • #28696
    Profile photo of Simeon Iksanov
    Simeon Iksanov
    Participant

    try this:

    Add-ADGroupMember -Identity 'somegroup_in_domain_1' -Members (get-aduser -Filter * -Server "domain_controller_2")

You must be logged in to reply to this topic.