Ad Widget

Collapse

Get Exchange CMDLETS value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blinding
    Junior Member
    • May 2015
    • 6

    #1

    Get Exchange CMDLETS value

    I want to get the cmdlets of exchange "Get-queue", but i cant get the script to work with this. This is what i have:

    On Exchange Side:

    UserParameter=queue.check, powershell.exe -NoProfile -ExecutionPolicy Bypass -file "C:\Program Files\Zabbix\scripts\QueueCheck.ps1"

    On Script on exchange

    ----------------------------------------------------------
    Code:
    $exchangeServer = "exchangeserver"| Where {
        Test-Connection -ComputerName $_ -Count 1 -Quiet
    } | Get-Random
    
    $password = ConvertTo-SecureString "somepass*" -AsPlainText -Force
    $cred= New-Object System.Management.Automation.PSCredential ("username", $password )
    $ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri ("http://{0}.domain/PowerShell" -f $exchangeServer) -Authentication Kerberos -Credential $cred
    Import-PSSession $ExchangeSession
    
    
    $value = get-queue -Filter {MessageCount -gt 25 } | foreach MessageCount 
    
    if($value.Count -eq 0){
      Write-Output 1
    }else {
       Write-Output 0
      }
    
    Remove-PSSession $ExchangeSession

    I want to get 1 if no more than 25 on Queue and 0 if they are. But Only get. System interrupted call on zabbix server.

    Running this script on server return as desired. Help needed
Working...