Get members of group in Active directory using Powershell

First we need to import AD module on domain controller:

Import-Module ActiveDirectory
Get-ADUser –identity <alias> –Properties *

Get a list of members of an AD security group using PowerShell:

Get-ADGroupMember “<GroupName>” | Select Name, SamAccountName, objectClass

Or,Get a list of user ojectClasses only, run:

Get-ADGroupMember “<GroupName>” | where {$_.objectclass-eq “user”} | Select Name, SamAccountName

Get a list of group objectClasses only:

Get-ADGroupMember “<GroupName>” | where {$_.objectclass-eq “group”} | Select Name, SamAccountName

Now get PrimarySmtpAddress field and do a custom search for email addresses like *@domain.com

Get-Mailbox | Where-Object {$_.PrimarySmtpAddress –like "*@domain.com"}
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