Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# copied some parts of this script from
#$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
# 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
You can’t perform that action at this time.