Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Search AD Users That Not Match With Some Group

$
0
0

Hi Folks !!!

I'm 2 groups named group1 and group2 and I need get all user of the group1 and all users of the group2... I have this script:

Get-ADUser -Filter * -Properties * | where {$_.MemberOf -match "Group1" -and $_.Enabled -eq "True"} | select Name, LastLogonDate | Sort-Object Name

This work fine for me, but when I trying to get all users outside these groups I trying this:

Get-ADUser -Filter * -Properties * | where {$_.MemberOf -notmatch "Group1" -and $_.Enabled -eq "True"} | select Name, LastLogonDate | Sort-Object Name

This return me some users that's in Group1 or Group2 too...

Any suggestion !?


Jimcesse
Principal: http://sysadmin-cr.com/
Alterno: http://blogs.itpro.es/jimcesse


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>