Powershell Script to List Domain Admins with Mailboxes in Exchange 2010

Hi,

Do you know Powershell command or script I can use to list Domain Admins with Mailboxes in Exchange 2010

Best Regards,

Mark
makel2Asked:
Who is Participating?
 
MaheshConnect With a Mentor ArchitectCommented:
Try below code from active directory PowerShell (will work on 2008 R2 / 2012 DCs)
The script will check all members of domain admins and export output only for those users who have mailbox by looking homeMDB attribute

Import-Module ActiveDirectory -ErrorAction Stop

$grpmember = Get-ADGroupMember "Domain admins"

foreach ($member in $grpmember) {

Get-ADUser -Identity $member.SamAccountName -Properties Name, homeMDB | ? {$_.homeMDB -ne $null} | Select Name, homeMDB | Export-Csv C:\mbx.csv -Append -Force -NTI

}

Open in new window

1
 
Tom CieslikIT EngineerCommented:
For example this one.
You will get Domain admin, Group name in DC and Last Logged time

Get-ADGroupMember "Domain ADmins" | Get-AdUser -Property LastLogonDate | select name,distinguishedName,LastLogonDate

Open in new window

0
 
makel2Author Commented:
Hi thanks for that but will the PowerShell command also show that the Group member also has a Mailbox?
0
Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

 
Tom CieslikIT EngineerCommented:
You can try this one

$mailboxes = @(Get-ADGroupMember "Domain Admins" | ForEach-Object { get-mailbox $_.distinguishedname })

Open in new window


This will work if all members has mailbox
0
 
Senior IT System EngineerIT ProfessionalCommented:
Mahesh, does the Power Shell script can be executed on Exchange 2013 or 2016 as well ?
0
 
MaheshArchitectCommented:
The script can be executed from any server where AD PowerShell module is available
So does your exchange servers also have ad PowerShell module so you can execute from there as well
1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.