Wednesday, September 18, 2013

Powershell - The Big All-in-One All Exchange 2010 DAG Mailboxes in a Site Query

9/18/2013: Here's a one-line Exchange Management Shell Powershell command that will retrieve useful attributes on all Exchange 2010 DAG-hosted mailboxes in the specified site.

Describing the process used by the command:
  1. Retrieve all exchange servers, that are Mailbox Servers, in the designated AD Site,with Exchange version 14 (Exchange 2010)
  2. Then retrieve all databases on those servers, where the ReplicationType attribute is 'Remote' (e.g. DAG replicated)
  3. Then retrieve all mailboxes in those databases, 
  4. And return a list of specific attributes of the mailbox, including a custom field that encapulates a semi-colon-delimited joined string created from all EmailAddresses of the mailbox. 
  5. And finally, export that collection of data to a csv file.

Static-source follows (for folks in RSS readers, or disabling scripting):
(check the linked Gist/Github links below for _current_ versions).

# one-line follows
get-exchangeserver | 
    where { $_.IsMailboxServer -eq $true -AND $_.Site -like '*SiteA*' -AND $_.admindisplayversion.major -eq 14 } | 
        get-mailboxdatabase | 
            where {$_.ReplicationType -eq "Remote"} | 
                get-mailbox -resultsize unlimited | 
                    select samaccountname,DisplayName,Alias, Office,WindowsEmailAddress, @{Name='Addresses';Expression={[string]::join(";", ($_.EmailAddresses))}}, Database,ServerName,IsResource,IsLinked,IsShared, UseDatabaseQuotaDefaults,IssueWarningQuota, ProhibitSendQuota,ProhibitSendReceiveQuota, ArchiveDatabase,ArchiveGuid,ArchiveName, ArchiveQuota,ArchiveWarningQuota,WhenMailboxCreated, HasPicture,HasSpokenName,OrganizationalUnit, LegacyExchangeDN,PrimarySmtpAddress,RecipientType, RecipientTypeDetails,RequireSenderAuthenticationEnabled, SimpleDisplayName,ExchangeVersion,Name,DistinguishedName, Guid,ObjectCategory,WhenChanged,WhenCreated |
                        export-csv .\Ex2010-mbx-users.csv -notype ;
} ;

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.