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

Welcome Forums General PowerShell Q&A 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

 
Participant
3 years, 3 months ago.

  • Author
    Posts
  • #28690

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 4
    Rank: Member

    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

    Participant
    Points: 1
    Rank: Member

    try this:

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

The topic ‘How to add or remove Entire Directory users from any group in Active Directory’ is closed to new replies.