#region Load Exchange Snap-in if (!(Get-Command Get-ExchangeServer -ErrorAction SilentlyContinue)) { if (Test-Path "C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1") { . 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1' Connect-ExchangeServer -auto } elseif (Test-Path "C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1") { Add-PSSnapIn Microsoft.Exchange.Management.PowerShell.Admin .'C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1' } else { throw "Exchange Management Shell cannot be loaded" } } #endregion Load Exchange Snap-in #region HTML Start $HTML=' IAMGOLD Exchange Environment

Exchange Environment

Generated ' + $((Get-Date).ToString()) + '


Table of contents
Exchange Server Information
Database Availability Group Information
Databases Information
Client Access Server Information
CAS Array Information
Transport Server Information
Transport Costs
Send Connectors
Accepted Domains
Email Address Policies
' #endregion HTML Start #region Get Exchange Servers $servers = Get-ExchangeServer | Sort-Object Site $HTML +='

Exchange Servers Information

' foreach ($exchangeserver in $servers) { $ServerName = $exchangeserver.name.ToUpper() $ServerMajorVersion = $exchangeserver.AdminDisplayVersion.Major if ($ServerMajorVersion -eq 14) { $ServerVersion = "Exchange 2010" } else { $ServerVersion = "Exchange 2013" } $ServerVersion += " (SP" + $exchangeServer.AdminDisplayVersion.Minor.ToString() + ") Build " + $exchangeServer.AdminDisplayVersion.Build.ToString() + "." + $exchangeServer.AdminDisplayVersion.Revision.ToString() $ServerSite = $exchangeserver.site.Name.ToString() $IP = Resolve-DnsName $exchangeserver.Name.ToString() $ServerIP = $IP.IPAddress.ToString() $ServerRoles = $exchangeserver.ServerRole.ToString() $HTML += ' ' } $HTML += '

Server Name

Version

Site

IP Address

Roles

' + $ServerName + ' ' + $ServerVersion + ' ' + $ServerSite + ' ' + $ServerIP + ' ' + $ServerRoles + '

Back to top
' #endregion Get Exchange Servers #region Get DAG Information $DAGs = Get-DatabaseAvailabilityGroup | Sort-Object Name $HTML +='

Database Availability Groups Information

' foreach ($DAG in $DAGs) { $DAGName = $DAG.Name $DAGIP = $DAG.DatabaseAvailabilityGroupIpv4Addresses $DAGMembers = $DAG.Servers $DAGWitnessServer = $DAG.WitnessServer $DAGWitnessDirectory = $DAG $HTML += ' ' } $HTML +='

DAG Name

IP Addresses

Members

Witness Server

Witness Directory

' + $DAGName + ' ' + $DAGIP + ' ' + $DAGMembers + ' ' + $DAGWitnessServer + ' ' + $DAGWitnessDirectory + '
Mailbox Databases ' $DAGDatabases = Get-MailboxDatabase | where {$_.MasterServerOrAvailabilityGroup -eq $dag.name} foreach ($DAGDB in $DAGDatabases) { $DBName = $DAGDB.Name $DBHostingServer = $DAGDB.Server.Name $HTML +='' } $HTML +='

Database Name

Hosting Server

Copies (Activation Preference)

' + $DBName + ' ' + $DBHostingServer + ' ' $DBCopies = $DAGDB.ActivationPreference foreach ($DBCopy in $DBCopies) { $DBCopyHost = $DBCopy.Key.Name $DBCopyPriority = $DBCopy.Value $HTML += '' } $HTML += '
' + $DBCopyHost + ' (' + $DBCopyPriority + ')

Back to top
' #endregion Get Dag Information #region Get Database Information $Databases = Get-MailboxDatabase | Sort-Object ServerName $HTML +='

Databases Information

' foreach ($Database in $Databases) { $DBName = $Database.Name $DBServer = $Database.ServerName $DBEdbPath = $Database.EdbFilePath.PathName $DBLogPath = $Database.LogFolderPath.PathName $DBRpcCAS = $Database.RpcClientAccessServer $DBOAB = $Database.OfflineAddressBook $DBDeletedItems = $Database.DeletedItemRetention.Days $DBCircularLogging = $Database.CircularLoggingEnabled $HTML += ' ' } $HTML += '

Database Name

Hosted On

EDB File Path

Log Folder Path

RPC Client Access Server

Offline Address Book

Deleted Item Retention

Circular Logging

' + $DBName + ' ' + $DBServer + ' ' + $DBEdbPath + ' ' + $DBLogPath + ' ' + $DBRpcCAS + ' ' + $DBOAB + ' ' + $DBDeletedItems + ' ' + $DBCircularLogging + '

Back to top
' #endregion Get Database Information #region Get CAS information $CASServers = Get-ClientAccessServer $HTML +='

Client Access Servers Information

' foreach ($CASServer in $CASServers) { $CASServerName = $CASServer.Name $CASSite = $CASServer.AutoDiscoverSiteScope $CASOAEnabled = $CASServer.OutlookAnywhereEnabled $HTML +=' ' } $HTML += '

Server Name

AutoDiscover Site

Outlook Anywhere Enabled

' + $CASServerName + ' ' + $CASSite + ' ' + $CASOAEnabled + '
OWA Virtual Directory ' $OWAVirtualDirectories = Get-OwaVirtualDirectory -Server $CASServerName foreach ($OWADirectory in $OWAVirtualDirectories) { $OWAVDName = $OWADirectory.name $OWAVDAuth = $OWADirectory.InternalAuthenticationMethods $OWAVDIntURL = $OWADirectory.InternalUrl $OWAVDExtURL = $OWADirectory.ExternalUrl $HTML += ' ' } $HTML +='
Name Internal Authentication Method Internal URL External URL
' + $OWAVDName + ' ' + $OWAVDAuth + ' ' + $OWAVDIntURL + ' ' + $OWAVDExtURL + '

Back to top
' #endregion Get CAS Information #region Get CAS Array $CASArrays = Get-ClientAccessArray | Sort-Object SiteName $HTML +='

CAS Array Information

' foreach ($CASArray in $CASArrays) { $CASArrayName = $CASArray.Name $CASArrayFQDN = $CASArray.Fqdn $CASArrayIP = Resolve-DnsName $CASArrayFQDN.ToString() $CASArraySite = $CASArray.SiteName $CASArrayMembers = $CASArray.Members $CASArrayDBs = Get-MailboxDatabase | where {$_.RpcClientAccessServer -eq $CASArrayFQDN} $HTML += ' ' } $HTML += '

Name

FQDN

IP

Site

Members

Used by Databases

' + $CASArrayName + ' ' + $CASArrayFQDN + ' ' + $CASArrayIP + ' ' + $CASArraySite + ' ' + $CASArrayMembers + ' ' $Count = $CASArrayDBs.Count Do { $HTML += $CASArrayDBs[$Count - 1].Name $Count = $Count - 1 If ($Count -ne 0) { $HTML += '
' } } Until ($Count -eq 0) $HTML += '

Back to top
' #endregion Get CAS Array #region Get Transport Servers $HubServers = Get-TransportServer | Sort-Object Name $HTML +='

Transport Servers Information

' foreach ($HubServer in $HubServers) { $HTML +=' ' $ReceiveConnectors = Get-ReceiveConnector -Server $HubServer.Name $HTML += ' ' } $HTML += '

Server Name

' + $Hubserver.Name + '
Receive Connectors ' foreach ($ReceiveConnector in $ReceiveConnectors) { $ConnectorName = $ReceiveConnector.Name $ConnectorAuth = $ReceiveConnector.AuthMechanism $ConnectorBindings = $ReceiveConnector.Bindings $ConnectorMax = $ReceiveConnector.MaxMessageSize $ConnectorPermission = $ReceiveConnector.PermissionGroups $ConnectorTLS = $ReceiveConnector.RequireTLS $HTML += ' ' } $HTML += '
Name Authentication Mechanism Bindings Permission Groups Max Message Size Requires TLS
' + $ConnectorName + ' ' + $ConnectorAuth + ' ' + $ConnectorBindings + ' ' + $ConnectorPermission + ' ' + $ConnectorMax + ' ' + $ConnectorTLS + '

Back to top
' #endregion Get Transport Servers #region Get Transport Costs $HTML +='

Transport Costs

' $Servers = Get-ExchangeServer | where {$_.IsHubTransportServer -eq $True} | Sort-Object Site $ServerCount = 0 Do{ $HTML +=' ' $ServerCount ++ } Until ($ServerCount -eq $Servers.Count-1) $HTML +=' ' foreach ($Server in $Servers) { $Count = 0 $ServerSite = $Server.Site.Name $HTML +=' ' Do{ $RemoteServerSite = $Servers[$Count].Site.Name If ($Server.Name -eq $Servers[$Count].Name) { $HTML +='' } ElseIf ($ServerSite -eq $RemoteServerSite) { $HTML +='' } Else { $ADSiteLinkCost = ((get-adsitelink) | where {($_.Sites).name -like $ServerSite -and ($_.Sites).name -like $RemoteServerSite}).adcost If ($ADSiteLinkCost) { If ($ADSiteLinkCost -eq 10) {$color = "green"} Else {$color = "yellow"} $HTML +=''} Else {$HTML +=''} } $Count ++ } Until ($Count -eq $Servers.Count -1) $HTML +='' } $HTML +='
' + $Servers[$ServerCount].Name + '
' + $Server.Name + '00' + $ADSiteLinkCost +'

0 Local MAPIDevlivery
10 Main Route
30-45 Backup Route
No Direct Route

Back to top
' #endregion Transport Costs #region Get Send Connector $SendConnectors = Get-SendConnector $HTML +='

Send Connectors

' foreach ($SendConnector in $SendConnectors) { $HTML += ' ' } $HTML += '

Connector Name

Address Spaces

Source Servers

MaxMessageSize

' + $SendConnector.Name + ' ' foreach ($AddressSpace in $SendConnector.AddressSpaces) { $Count = 1 $HTML += $AddressSpace.Type + ' : ' + $AddressSpace.Address + ' ; ' + $AddressSpace.Cost if ($Count -ne $AddressSpace.count){$HTML += '
'} $Count++ } $HTML +='
' foreach ($SourceServer in $SendConnector.SourceTransportServers) { $Count = 1 $HTML += $SourceServer.Name if ($Count -ne $SourceServer.count){$HTML += '
'} $Count++ } $HTML +='
' + $SendConnector.MaxMessageSize.Value.ToMB() + ' MB

Back to top
' #endregion Get External Connector #region Accepted Domain Name $AcceptedDomains = Get-AcceptedDomain $HTML +='

Accepted Domains

' foreach ($Domain in $AcceptedDomains) { $HTML += ' ' } $HTML += '

Domain Name

Domain Type

Default

' + $Domain.DomainName + ' ' + $Domain.DomainType + ' ' + $Domain.Default + '

Back to top
' #endregion Accepted Domain Name #region Email Address Policies $EmailPolicies = Get-EmailAddressPolicy $HTML +='

Email Address Policies

' foreach ($Policy in $EmailPolicies) { $HTML += ' ' } $HTML += '

Policy Name

Recipient Filter

Email Address Templates

' + $Policy.Name + ' ' + $Policy.RecipientFilter + ' ' foreach ($Template in $Policy.EnabledEmailAddressTemplates) { $HTML += '' } $HTML += '
Address TemplateTypePrimary
' + $Template.AddressTemplateString + '' + $Template.Prefix + '' + $Template.IsPrimaryAddress.ToString() + '


Back to top
' #endregion Email Address Policies #region End HTML File $HTML += ' ' #endregion End HTML File #Write HTML file echo $HTML > test.html
%g First Name
%s Last Name
%m Alias
%1g First letter of the First Name