locked
Remove-adgroupmember from CSV RRS feed

  • General discussion

  • hello Experts,

    We need to removed disabled members of certain AD groups. We were able to pull that information using PowerShell.  We have a CSV with samaccountname of disabled users in one column and names of corresponding groups in other column.

    Any pointers on how we can use remove-adgroupmember to do this task.

    Appreciate any help!

    • Changed type Bill_Stewart Monday, March 12, 2018 8:18 PM
    • Moved by Bill_Stewart Monday, March 12, 2018 8:18 PM This is not "scripts on demand"
    Tuesday, January 16, 2018 10:40 PM

All replies

  • Any pointers on how we can use remove-adgroupmember to do this task.

    Yes. We would recommend reading the documentation. Use a search engine. Examples:

    http://www.google.com/search?q=import-csv

    http://www.google.com/search?q=remove-adgroupmember

    The documentation should be one of the first search results.


    -- Bill Stewart [Bill_Stewart]


    Tuesday, January 16, 2018 10:48 PM
  • Hi All,

    I have csv with list of privileged groups. I would like to remove all disabled users from these privileged groups. I know how to remove disabled users from one group but not sure how to use for multiple groups that are in CSV.

    Any help will be appreciated.

    • Merged by Bill_Stewart Monday, January 29, 2018 4:01 PM Duplicate
    Thursday, January 18, 2018 9:51 PM
  • Here is one way

    Get-AdUser -Filter {Enabled=$false} -Properties memberof|
          ForEach-Obect{
                   foreach($group in $_.MemberOf){ Remove-AdGroupMember $_ -Member $_ }
         }
                   


    \_(ツ)_/

    Thursday, January 18, 2018 10:01 PM
  • thanks JRV!

    How do you specify the CSV containing group names here?

    Thursday, January 18, 2018 11:29 PM
  • help import-csv -online

    \_(ツ)_/

    Thursday, January 18, 2018 11:30 PM