Skip to content

Instantly share code, notes, and snippets.

@tostka
Last active September 22, 2017 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tostka/8386792cf24dc70f42759d96601dafbc to your computer and use it in GitHub Desktop.
Save tostka/8386792cf24dc70f42759d96601dafbc to your computer and use it in GitHub Desktop.
<# Powershell snippet to retrieve details on top 3 queued domains on Exchange hubs in local AD site
I generally just paste the 1-liner version straight into a remote EMS console, for execution
#>
$TopDoms=3 ;
$Site=[System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite().Name ;
$Banner="== v Site:$($Site.toupper()) - TOP $($TopDoms) QUEUED DOMAINS PER HUB: v ==" ;
write-host -foregroundcolor green "`n$((get-date).ToString('HH:mm:ss')):$($Banner)" ;
$hubsl=Get-ExchangeServer | where { $_.isHubTransportServer -eq $true -and $_.Site -match ".*\/$($Site)$"} | select -expand Name ;
foreach($hub in $hubsl){ write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):----$($hub):" ;
[console]::ForegroundColor = "yellow" ;
get-queue -server $hub -SortOrder:-MessageCount -Results:$TopDoms | fl ;
[console]::ResetColor() ;
} ;
write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):$($Banner.replace(' v ',' ^ '))`n" ;
<# same code unwrapped into a paste-able 1-liner:
$TopDoms=3 ;$Site=[System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite().Name ;$Banner="== v Site:$($Site.toupper()) - TOP $($TopDoms) QUEUED DOMAINS PER HUB: v ==" ;write-host -foregroundcolor green "`n$((get-date).ToString('HH:mm:ss')):$($Banner)" ;$hubsl=Get-ExchangeServer | where { $_.isHubTransportServer -eq $true -and $_.Site -match ".*\/$($Site)$"} | select -expand Name ;foreach($hub in $hubsl){ write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):----$($hub):" ; [console]::ForegroundColor = "yellow" ; get-queue -server $hub -SortOrder:-MessageCount -Results:$TopDoms | fl ; [console]::ResetColor() ;} ;write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):$($Banner.replace(' v ',' ^ '))`n" ;
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment