Pull AD Group Members and Member Properties

##Pull Active Directory Group Members, and Member Properties
##———————————————————–
##Get AD Groups via text file or Get-ADGroup command
$adGroups = Get-Content “C:\Temp\adGroups.txt”;
#$adGroups = Get-ADGroup -Filter *;

Foreach ( $group in $adGroups ) {
     $groupName = $group;
     #$groupName = $group.Name;
     $adGroupMembers = Get-ADGroupMember $groupName;

     Foreach ( $member in $adGroupMembers ) {
          $memberSamAcct = $member.SamAccountName;
          $adUser = Get-ADUser $memberName;
          ##Get other AD User attributes here
          echo “$groupName,$memberSamAcct”;
     }
}

Advertisements

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

%d bloggers like this: