How to display list Active Directory users that arent in specific AD Groups

316 views Asked by At

I have a requirment to create a report/text file that displays the users that arent in specific AD groups. I know displaying users that are in specific AD groups is easy enough with Powershell.

Surely its possible to display the users that ARENT in specific AD groups with powershell also ??

2

There are 2 answers

0
AudioBubble On
  1. Export a list of all users 'cn' in your active directory to a text file

    Get-ADUser | Select-Object sAMAccountname > c:\temp\directory list

  2. Depending on group sizes .netFramework has issues with groups with a large number of members (1500+) use 'dsget' to get a list of members in the group and store these into a variable

    $groupName = dsget group "groupname" -members

  3. compose foreach statement

if you need the actual code syntax -

  http://stackoverflow.com/questions/22145586/powershell-compare-csv-to-ad
0
Jermu Virtanen On

One approach:

  1. Export all users
  2. Export users that are members of that specific group
  3. Do excel work to find out users that aren't members

However, if the task is to perform it with powershell only, you have to do your research how to perform those steps without excel.