Determine who has a mailbox and remote mailbox via AD Powershell

Scenario:  You have a list of username’s in a .csv file with a column header labeled: name.  You want to quickly determine which usernames have a Mailbox and RemoteMailbox.

Script:

Import-module ActiveDirectory

$Members = Import-csv C:sharecvusers.csv | Select -ExpandProperty Name

$Members = $Members | Sort

$Members_OnPrem = @()
$Members_o365 = @()

$Members  | %{
    "$_"
    $type = Get-ADUser $_ -properties msExchRecipientTypeDetails | Select -ExpandProperty MSexchRecipientTypeDetails
         If ($type -eq "1"){$Members_OnPrem += $_}
         If ($type -eq "2147483648"){$Members_o365 += $_}
}


Advertisement

One thought on “Determine who has a mailbox and remote mailbox via AD Powershell”

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 )

Connecting to %s

%d bloggers like this: