SouravA SouravA - 2 months ago 4x
PowerShell Question

Get a list of users who are not part of ANY group in the active directory

On the internet as well as SO, I can see solutions for finding out all the users in AD or users who are not part of some particular group/groups. But I want to have a list of users not part of ANY group(i.e. part of Domain Users only). I have a lot of AD groups and it is impractical to hard code it in the script. I also know about the CSVDE tool and have been able to extract the data out of it, but unfortunately the output is quite convoluted and not user friendly. What I am looking for is to extract this information in two columns -

in a flat file. A PowerShell solution is preferable but I am open to any solutions as long as it doesn't involve installing any third party software as it is not allowed in my organization.


Just like this:

Get-ADUser -LdapFilter "(!memberOf=*)" -Properties memberOf | Select-Object SamAccountName, MemberOf