Last active
November 25, 2016 15:41
-
-
Save theeye-io/ed1f2407b3d3aae90a69af064c3e204a to your computer and use it in GitHub Desktop.
CheckExchangeMailQueue2013
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# copied some parts of this script from | |
# https://gallery.technet.microsoft.com/office/e0bb250e-e699-4c6c-a5be-f1af245a2219 | |
# | |
#$queueThreshold=$args[0] | |
$queueThreshold=50 | |
#$domainUser=$args[1] | |
#$domainUser= | |
#$s = New-PSSession -Credential domain\user | |
#Import-PSSession $s | |
#Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2013 | |
. 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1' | |
Connect-ExchangeServer -auto | |
#Get-Queue -identity submission | |
$MessageCount = Get-Queue | foreach -begin {$total=0} -process {$total+=$_.messageCount} -end {$total} | |
Write-Host $MessageCount | |
if ([int]$MessageCount -gt [int]$queueThreshold){ | |
$out = @{state="failure";data=@{message_count=$MessageCount}} | |
} else { | |
$out = @{state="success";data=@{message_count=$MessageCount}} | |
} | |
$json = $out | ConvertTo-Json -Compress | |
Write-Host $json | |
Exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# runas | |
powershell.exe -NonInteractive -ExecutionPolicy ByPass -File "%script%" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment