# ExchSummary.PS1 # Author: Doug Blanchard # The script collects some summary information about the Exchange 2007 Messaging Environment # Security: You may need to run [ Set-ExecutionPolicy Unrestricted ] prior to running this script # Usage: no arguments needed $error.clear() # Create a record of the PowerShell session to a text file. start-transcript -path C:\ExchTscript.txt | out-null # Create ExchData Folder on C: Drive to store all information if(!(test-path c:\ExchData -pathtype container)){new-item c:\ExchData -type directory | out-null} # Check if Log file already exist if(test-path c:\ExchData\ExchSummary.log -pathtype leaf){rename-item -path c:\ExchData\ExchSummary.log -newname ExchSum_old.log | out-null} Write-Output " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ " Write-Output " ++ This script is collecting summary information about the Exchange ++ " Write-Output " ++ and Active Directory environment. Files are located in the ++ " Write-Output " ++ C:\ExchData directory. ++ " Write-Output " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ " Write-Output " " Write-Output " Collecting Exchange summary information..." Write-Output " " Get-Date | out-file C:\ExchData\ExchSummary.log Write-host " Do you want to run the Exchange Best Practice Analyzer (EXBPA)? (y/n)" -ForegroundColor Green $Exbpa = Read-Host Switch ($Exbpa) { "y" {Write-Output " Running EXBPA...this may take awhile" ; Exbpacmd -dat C:\ExchData\EXBPAHealthCheck.xml | out-null} "n" {Write-Output " Skipping EXBPA" ; "NOTE: EXBPA was not run" | out-file C:\ExchData\ExchSummary.log -append} default {Write-output " Skipping EXBPA" ; "NOTE: EXBPA was not run" | out-file C:\ExchData\ExchSummary.log -append} } " " >> C:\ExchData\ExchSummary.log Write-host " Obtaining Active Directory Summary..." " =============================================================== " >> C:\ExchData\ExchSummary.log " == ACTIVE DIRECTORY SUMMARY == " >> C:\ExchData\ExchSummary.log " =============================================================== " >> C:\ExchData\ExchSummary.log $objForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() $objDomain = [System.DirectoryServices.ActiveDirectory.Domain]::getcurrentdomain() "Forest Name: " +$objForest.Name >>C:\ExchData\ExchSummary.log "Number of domains in forest: " +$objForest.Domains.count >>C:\ExchData\ExchSummary.log "Number of sites in forest: " +$objForest.Sites.count >>C:\ExchData\ExchSummary.log "Number of Global Catalog Servers in Forest: " +$objForest.FindAllGlobalCatalogs().count >>C:\ExchData\ExchSummary.log "Number of Trust Relationships in Forest: " +$objForest.GetAllTrustRelationships().count >>C:\ExchData\ExchSummary.log "Name of Current Domain: " +$objDomain.Name >>C:\ExchData\ExchSummary.log "Number of Domain Controllers in current Domain: " +$objDomain.FindAllDomainControllers().count >>C:\ExchData\ExchSummary.log "Schema Master Role Owner: " +$objForest.SchemaRoleOwner >>C:\ExchData\ExchSummary.log "Naming Role Owner: " +$objForest.NamingRoleOwner >>C:\ExchData\ExchSummary.log "PDC Emulator Role Owner: " +$objDomain.PdcRoleOwner >>C:\ExchData\ExchSummary.log "RID Role Owner: " +$objDomain.RidRoleOwner >>C:\ExchData\ExchSummary.log "Infrastructure Role Owner: " +$objDomain.InfrastructureRoleOwner >>C:\ExchData\ExchSummary.log $objForest = $Null $objDomain = $Null " " >> C:\ExchData\ExchSummary.log " " >> C:\ExchData\ExchSummary.log Write-host " Obtaining Exchange Server Summary..." Get-ExchangeAdministrator | ForEach-Object {$Admin++} Get-ExchangeServer |Select Name | ForEach-Object {$GetSvr++} Get-MailContact -Resultsize Unlimited |Select Name | ForEach-Object {$GetContact++} Get-Mailbox -Resultsize Unlimited | Select Name | ForEach-Object {$GetMbx++} Get-DynamicDistributionGroup -Resultsize Unlimited | Select Name | ForEach-Object {$GetDynGrp++} Get-DistributionGroup -Resultsize Unlimited | ForEach-Object {$GetDL++} " =============================================================== " >> C:\ExchData\ExchSummary.log " == EXCHANGE ORGANIZATION SUMMARY == " >> C:\ExchData\ExchSummary.log " =============================================================== " >> C:\ExchData\ExchSummary.log " # of Exchange Administrators: " +$Admin >> C:\ExchData\ExchSummary.log " # of Exchange Servers: " +$GetSvr >> C:\ExchData\ExchSummary.log " # of Mailboxes: " +$GetMbx >> C:\ExchData\ExchSummary.log " # of Contacts: " +$GetContact >> C:\ExchData\ExchSummary.log " # of Dynamic Distribution List: " +$GetDynGrp >> C:\ExchData\ExchSummary.log " # of Distribution List: " +$GetDL >> C:\ExchData\ExchSummary.log # Cleanup of Organization $Admin = $null $GetSvr = $Null $GetDL = $Null $GetDynGrp = $Null $GetContact = $Null $GetMbx = $Null # Mailbox Organization Write-host " Obtaining Organization - Mailbox Summary..." Get-AddressList | ForEach-Object {$GetAdd++} Get-GlobalAddresslist | ForEach-Object {$GetGAL++} Get-OfflineAddressBook | ForEach-Object {$GetOAB++} Get-ManagedContentSettings | ForEach-Object {$GetMgCS++} Get-ManagedFolder | Where {$_.FolderType -eq "ManagedCustomFolder"} | ForEach-Object {$GetMgdFld++} Get-ManagedFolderMailboxPolicy | ForEach-Object {$GetMgdFMPol++} " " >> C:\ExchData\ExchSummary.log " ORGANIZATION - MAILBOX " >> C:\ExchData\ExchSummary.log " # of Address List: " +$GetAdd >> C:\ExchData\ExchSummary.log " # of Global Address List: " +$GetGAL >> C:\ExchData\ExchSummary.log " # of Offline Address List: " +$GetOAB >> C:\ExchData\ExchSummary.log IF ($GetMgCS -ne $null) { " (NON-DEFAULT) -- # of Managed Default Folders Defined: " +$GetMgCS >> C:\ExchData\ExchSummary.log } IF ($GetMgdFld -ne $null) { " (NON-DEFAULT) -- # of Custom Managed Folders Defined: " +$GetMgdFld >> C:\ExchData\ExchSummary.log } IF ($GetMgdFMPol -ne $null) { " (NON-DEFAULT) -- # of Managed Mailbox Folder Policy Defined: " +$GetMgdFMPol >> C:\ExchData\ExchSummary.log } # Cleanup Mailbox Organization $GetAdd = $null $GetGAL = $null $GetOAB = $null $GetMgCS = $null $GetMgdFld = $null $GetMgdFMPol = $null " " >> C:\ExchData\ExchSummary.log Write-host " Obtaining Organization - Client Access Summary..." " ORGANIZATION - CLIENT ACCESS" >> C:\ExchData\ExchSummary.log Get-ActiveSyncMailboxPolicy | ForEach {$GetAct++} " # of ActiveSync Mailbox Policies Defined: " +$GetAct >> C:\ExchData\ExchSummary.log $GetAct = $Null " " >> C:\ExchData\ExchSummary.log Write-host " Obtaining Organization - Hub Transport Summary..." " ORGANIZATION - HUB TRANSPORT" >> C:\ExchData\ExchSummary.log Get-RemoteDomain | ForEach {$GetRemDom++} " # of Remote Domains: " +$GetRemDom >> C:\ExchData\ExchSummary.log Get-AcceptedDomain | ForEach {$GetAcpDom++} " # of Accepted Domains: " +$GetAcpDom >> C:\ExchData\ExchSummary.log Get-SendConnector | ForEach {$GetSend++} " # of Send Connectors: " +$GetSend >>C:\ExchData\ExchSummary.log Get-EdgeSubscription | ForEach {$GetEdge++} " # of Edge Subscriptions: " +$GetEdge >>C:\ExchData\ExchSummary.log Get-EmailAddressPolicy | ForEach {$GetEmlPol++} " # of Email Address Policies: " +$GetEmlPol >> C:\ExchData\ExchSummary.log Get-TransportRule | ForEach {$GetTrsRul++} IF ($GetTrsRul -ne $null) { " (NON-DEFAULT) -- # of Transport Rules Defined: " +$GetTrsRul >> C:\ExchData\ExchSummary.log } Else{" No Transport Rules Found" | Out-file C:\ExchData\ExchSummary.log -append} Get-JournalRule | ForEach {$GetJrnRul++} IF ($GetJrnRul -ne $null) { " (NON-DEFAULT) -- # of Journal Rules Defined: " +$GetJrnRul >> C:\ExchData\ExchSummary.log } Else{" No Journal Rules Found" | Out-file C:\ExchData\ExchSummary.log -append} # Cleanup of Hub Organization $GetRemDom = $Null $GetAcpDom = $Null $GetSend = $Null $GetEdge = $Null $GetEmlPol = $Null $GetTrsRul = $Null $GetJrnRul = $Null " " >> C:\ExchData\ExchSummary.log " " >> C:\ExchData\ExchSummary.log " =============================================================== " >> C:\ExchData\ExchSummary.log " == EXCHANGE SERVER INFORMATION == " >> C:\ExchData\ExchSummary.log " =============================================================== " >> C:\ExchData\ExchSummary.log Write-host " Obtaining Exchange Server Summary..." Get-ExchangeServer | where {$_.ServerRole -ne "Edge"} | sort Name | FT Name,ServerRole,Edition,Site -auto -wrap >> C:\ExchData\ExchSummary.log " " >> C:\ExchData\ExchSummary.log Get-TransportServer | Foreach {$GetMsg++} Get-ClientAccessServer | Foreach {$GetCAS++} Get-MailboxServer | Foreach {$GetMMbx++} Get-UMServer | Foreach {$GetUM++} " Found " + $GetMsg + " Transport Servers..." >> C:\ExchData\ExchSummary.log " Found " + $GetCAS + " Client Access Servers..." >> C:\ExchData\ExchSummary.log " Found " + $GetMMbx + " Mailbox Servers..." >> C:\ExchData\ExchSummary.log If($GetUM -eq $Null){" There are NO Unified Messaging Servers deployed" | Out-file C:\ExchData\ExchSummary.log -append} Else{" There are " +$GetUM +"Unified Messaging Servers deployed" | Out-file C:\ExchData\ExchSummary.log -append} # Cleanup of Exchange Server Info $GetMsg = $Null $GetCAS = $Null $GetMMbx = $Null $GetUM = $Null " " >> C:\ExchData\ExchSummary.log " " >> C:\ExchData\ExchSummary.log " =============================================================== " >> C:\ExchData\ExchSummary.log " == EXCHANGE STORAGE GROUP / DATABASE SUMMARY == " >> C:\ExchData\ExchSummary.log " =============================================================== " >> C:\ExchData\ExchSummary.log Write-Output " Writing Storage Group info..." $GetSG = Get-StorageGroup -IncludePreExchange2007 "There are " + $GetSG.Count +" Storage Groups in the organization" >> C:\ExchData\ExchSummary.log Get-MailboxServer | Get-PublicFolderDatabase -IncludePreExchange2007 | Where{$_.objectClass -eq "msExchPublicMDB"} |ForEach {$GetPFSt++} "There are " + $GetPFSt + " Public Folder Stores within the Organization" >> C:\ExchData\ExchSummary.log Get-MailboxServer | Get-MailboxDatabase -IncludePreExchange2007 |ForEach {$GetMBSt++} "There are " + $GetMBSt + " Mailbox Stores within the Organization" >> C:\ExchData\ExchSummary.log $GetPFSt = $Null $GetMBSt = $Null $GetSG | where{$_.CircularLoggingEnabled -eq "True"} |ForEach {$GetCirLog++} If($GetCirLog -ne $Null){" (NON-DEFAULT) -- Circular Logging: Found " +$GetCirLog +" Storage Groups that have Circular Logging Enabled in the environment!" | Out-file C:\ExchData\ExchSummary.log -append} Else{"Circular Logging: No storage groups were found to have circular logging enabled in the environment" | Out-file C:\ExchData\ExchSummary.log -append} $GetSG | where{$_.HasLocalCopy -ne $Null} |ForEach {$GetLCR++} If($GetLCR -ne $Null){" (NON-DEFAULT) -- LCR: Local Continuous Replication was found on " +$GetLCR +" Storage Groups in the environment!" | Out-file C:\ExchData\ExchSummary.log -append} Else{"LCR: No storage groups were found to LCR enabled in the environment" | Out-file C:\ExchData\ExchSummary.log -append} $GetSG | where{$_.StandbyMachines -ne $Null} |ForEach {$GetSCR++} If($GetSCR -ne $Null){" (NON-DEFAULT) -- SCR: Standby Continuous Replication was found on " +$GetSCR +" Storage Groups in the environment!" | Out-file C:\ExchData\ExchSummary.log -append} Else{"SCR: No storage groups were found to SCR enabled in the environment" | Out-file C:\ExchData\ExchSummary.log -append} $GetSG | where{$_.Recovery -eq "True"} |ForEach {$GetRSG++} If($GetRSG -ne $Null){" (NON-DEFAULT) -- Found " +$GetRSG +" Recovery Storage Group in the environment!" | Out-file C:\ExchData\ExchSummary.log -append} Else{" No recovery storage groups were found in the environment" | Out-file C:\ExchData\ExchSummary.log -append} # Cleanup SG $GetRSG = $Null $GetSG = $Null $GetCirLog = $Null $GetSCR = $Null $GetLCR = $Null $GetSearch = Get-MailboxServer | Get-MailboxDatabase | Where{$_.IndexEnabled -ne "True"} If($GetSearch -ne $Null){" (NON-DEFAULT) -- Found " +$GetSearch.count +" Mailbox Databases that have Search set to DISABLED!" | Out-file C:\ExchData\ExchSummary.log -append} Else{" All Mailbox Databases have Search Enabled" | Out-file C:\ExchData\ExchSummary.log -append} $GetSearch = $Null Write-Output " Obtaining Storage Group Copy Status..." " " >> C:\ExchData\ExchSummary.log " " >> C:\ExchData\ExchSummary.log " STORAGE GROUP COPY STATUS " >> C:\ExchData\ExchSummary.log $GetSG = Get-StorageGroup | Where{$_.Recovery -ne "True"} $GetCopy = $GetSG | Get-StorageGroupCopyStatus | where{(($_.SummaryCopyStatus -ne "Disabled")-or($_.SummaryCopyStatus -ne "NotSupported"))} If($GetCopy -ne $Null){$GetCopy | FT -auto -wrap | Out-file C:\ExchData\ExchSummary.log -append} Else{" All Storage Groups Copy Status is set to Disabled" | Out-file C:\ExchData\ExchSummary.log -append} $GetSG = $Null $GetCopy = $Null Write-Output " Obtaining Backup Status Summary..." " " >> C:\ExchData\ExchSummary.log " " >> C:\ExchData\ExchSummary.log " DATABASE FULL BACKUP STATUS " >> C:\ExchData\ExchSummary.log Get-MailboxServer | Get-MailboxDatabase | FT StorageGroup,Name,LastFull* -auto -wrap >> C:\ExchData\ExchSummary.log Get-MailboxServer | Get-PublicFolderDatabase | Where{$_.objectClass -eq "msExchPublicMDB"} | FT StorageGroup,Name,LastFull* -auto -wrap >> C:\ExchData\ExchSummary.log " " >> C:\ExchData\ExchSummary.log " " >> C:\ExchData\ExchSummary.log " =============================================================== " >> C:\ExchData\ExchSummary.log " == EXCHANGE ROUTING SUMMARY == " >> C:\ExchData\ExchSummary.log " =============================================================== " >> C:\ExchData\ExchSummary.log Write-Output " Obtaining Routing Summary..." $GetTransportConfig = Get-TransportConfig $GetAdSiteLink = Get-AdSiteLink $GetForeign = Get-ForeignConnector $GetRGC = Get-RoutingGroupConnector $GetSendCon = Get-SendConnector $GetRcvCon = Get-ReceiveConnector " " >> C:\ExchData\ExchSummary.log " --- MESSAGE SIZE RESTRICTIONS --- " >> C:\ExchData\ExchSummary.log "Transport Config Size Settings" >> C:\ExchData\ExchSummary.log $GetTransportConfig | FT Name,*Size -auto -wrap >> C:\ExchData\ExchSummary.log "AD Site Link Size Settings" >> C:\ExchData\ExchSummary.log $GetAdSiteLink | FT Name,MaxMessageSize -auto -wrap >> C:\ExchData\ExchSummary.log "Foreign Connector Size Settings" >> C:\ExchData\ExchSummary.log $GetForeign | FT Name,MaxMessageSize -auto -wrap >> C:\ExchData\ExchSummary.log "Routing Group Connector Size Settings" >> C:\ExchData\ExchSummary.log $GetRGC | FT Name,MaxMessageSize -auto -wrap >> C:\ExchData\ExchSummary.log "Send Connector Size Settings" >> C:\ExchData\ExchSummary.log $GetSendCon | FT Name,MaxMessageSize,AddressSpaces -auto -wrap >> C:\ExchData\ExchSummary.log "Receive Connector Size Settings" >> C:\ExchData\ExchSummary.log $GetRcvCon | FT Name,MaxMessageSize,Permiss* -auto -wrap >> C:\ExchData\ExchSummary.log " " >> C:\ExchData\ExchSummary.log " --- CHECK FOR CUSTOM EXCHANGE COST CONFIGURED ON THE AD SITE LINK --- " >> C:\ExchData\ExchSummary.log If($GetAdSiteLink.ExchangeCost -ne $Null){"Site Link " +$_.Name +" has a custom Exchange cost configured. ." | Out-File C:\ExchData\ExchSummary.log -append} Else{"There are no custom Exchange cost defined on the AD Site links (ExchangeCost)" | Out-File C:\ExchData\ExchSummary.log -append} " " >> C:\ExchData\ExchSummary.log " --- CHECK IF MESSAGE TRACKING IS ENABLED ---" >> C:\ExchData\ExchSummary.log $GetMsg = Get-TransportServer $GetMMbx = Get-MailboxServer $GetMsg | Foreach-Object { if($_.MessageTrackingLogEnabled -ne "True") {"Message tracking log is not enabled on HUB Transport server: " +$_.Name | out-file C:\ExchData\ExchSummary.log -append} Else{" Message tracking is enabled on HUB Transport server: " +$_.Name | Out-file C:\ExchData\ExchSummary.log -append} } $GetMMbx | Foreach-Object { if($_.MessageTrackingLogEnabled -ne "True") {"Message tracking log is not enabled on Mailbox server: " +$_.Name | out-file C:\ExchData\ExchSummary.log -append} Else{" Message tracking is enabled on Mailbox server: " +$_.Name | Out-file C:\ExchData\ExchSummary.log -append} } $GetMsg = $Null $GetMMbx = $Null " " >> C:\ExchData\ExchSummary.log " " >> C:\ExchData\ExchSummary.log # Cleanup of Transport $GetTransportConfig = $Null $GetAdSiteLink = $Null $GetForeign = $Null $GetRGC = $Null $GetSendCon = $Null $GetRcvCon = $Null $GetMsgTrkTran = $Null $GetMsgTrkMbx = $Null " " >> C:\ExchData\ExchSummary.log " Data Collection Complete! " >> C:\ExchData\ExchSummary.log Write-Output "Summary Data Collection Complete!" Write-Output " " Write-Output " " Write-host " " Write-host " ====================================================== " -ForegroundColor Blue Write-host " == == " -ForegroundColor Blue Write-host " == ! Completed Exchange Report ! == " -ForegroundColor Blue Write-host " == Output is stored in C:|ExchData Directory == " -ForegroundColor Blue Write-host " == == " -ForegroundColor Blue Write-host " ====================================================== " -ForegroundColor Blue stop-transcript | out-null Move-item -path C:\ExchTscript.txt -destination C:\Exchdata