Hi Thwack Community,
I'm writing a powershell monitor to review the status of servers running in a Storage Replica. The idea is that they will review the "IsPrimary" Value, and if the value is true it will check whether shares are available, and if not then the monitor is down.
I have '${Caption}' defined in the Script Arguments, and I am running in Local Host mode.
The script is as below:
Invoke-Command -Computername '${Caption}' -UseSSL -Credential '${Credential} -ScriptBlock {
$SMBShareCheck = Get-SMBShare | measure
$Primary = "True"
$SRMemberStatus = Get-SRGRoup | Select-Object -ExpandProperty IsPrimary
If ($SRMemberStatus -eq $Primary){
If ($SMBShareCheck.Count -lt 1){
Write-Host 'Down'; Exit 1
}
else
{Write-Host 'Up'; Exit 0}
}
else
{Write-Host 'Up'; Exit 0}
}
I have tested this from the poller using Powershell ISE and it works great. If I use it in the Monitor I get
"Output Result:
Anyone know what I'm doing wrong?