Identify users in Groups by powershell

New task: list of users in Group (in ex. Domain Admins):

#Script is writen by: Mykola Korkishko and Andryi Svintsitsky

$array =@()
 $AllUsers=Get-ADUser -Properties * -Filter *
 foreach($user in $AllUsers){
 #$Groups=$user |select -ExpandProperty Memberof
 if ($user.MemberOf.Contains("CN=Domain Admins,CN=Users,DC=rcadv,DC=com") -and $user.Enabled -eq $true){
 $array+=$user.name
 }

}
 $array | out-file domain_adm_group.txt
Advertisements

About nicoljako

CTO of Exelegent, sysadmin, architect of IT infrastructures​
This entry was posted in Windows Server and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s