Friday, January 29, 2016

Find enabled Users not Member of Groups

Not member of group


(get-aduser -searchbase "OU=Test,DC=Test,DC=com" -Server test.com  -filter {(enabled -eq $true) -and ((memberof -ne "CN=Group1,OU=Groups,DC=test,DC=com") -and (memberof -ne "CN=Group2,OU=Groups,DC=test,DC=com"))}) |select UserPrincipalName |sort UserPrincipalName

No comments: