0 Replies Latest reply on Jul 18, 2018 9:15 AM by iansterling1982

    Powershell Component Monitor with Kemp - No Output

    iansterling1982

      I'm quite new to all the parts of this (Kemp, Powershell and Solarwinds Components) so there is quite likely something straight forward I have missed here but i'm banging my head against the wall to figure out what.

       

      I have written a Powershell script which works both from my machine and direct on the Orion server through Powershell ISE, however when i enter the below into the edit script box in a new template the Get Script Output returns Not Defined.

       

      For reference the Kemp Powershell module has been saved into both System 32 and SysWow64 folders, I have tried setting platform to run polling job on as x86 and x64 and I have amended the Kemp.Powershell.Module.psd1 file as discussed in another forum post to comment out the PowerShellHostVersion which by default is set to 2.0

       

      Any help would me much appreciated!

       

      PS Imagine my code might look overly complicated but i'm still learning and it works so consider that bit a work in progress!

       

      #Import Powershell Module

      Import-Module Kemp.Loadbalancer.Powershell

       

       

      #Set Load Balancer to Query

      $LoadBalancer = '*******'

       

       

      $KempPort = 443

       

       

      $KempAdmin = '***'

       

       

      $KempPassword = '*******'

       

       

      $SecureString = ConvertTo-SecureString -String $KempPassword -AsPlainText -Force

       

       

      $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $KempAdmin, $SecureString

       

       

      #Initialise connection to Kemp Loadbalancer

      Initialize-LoadBalancer -Address $LoadBalancer -LBPort $KempPort -Credential $credential

       

       

      #Add all Virtual services and data into a array variable

      [array]$VSArray = (Get-AdcVirtualService)

       

       

       

       

      $VSName = $VSArray.Data.VS[6].Nickname

      $RSTotal = $VSArray.Data.VS[6].NumberOfRSs

      $VSIP = $VSArray.Data.VS[6].VSAddress

      $VSEnabled = $VSArray.Data.VS[6].Enable

      $RS1Status = $VSArray.Data.VS[6].Rs[0].Status

      $RS1IP = $VSArray.Data.VS[6].Rs[0].Addr

      $RS1Enabled = $VSArray.Data.VS[6].Rs[0].Enable

      $RS2Status = $VSArray.Data.VS[6].Rs[1].Status

      $RS2IP = $VSArray.Data.VS[6].Rs[1].Addr

      $RS2Enabled = $VSArray.Data.VS[6].Rs[1].Enable

      $RS3Status = $VSArray.Data.VS[6].Rs[2].Status

      $RS3IP = $VSArray.Data.VS[6].Rs[2].Addr

      $RS3Enabled = $VSArray.Data.VS[6].Rs[2].Enable

       

       

       

       

      $RS1Count = ($RS1Enabled.ToCharArray() | Where-Object {$_ -eq 'Y'} | Measure-Object).Count

      $RS2Count = ($RS2Enabled.ToCharArray() | Where-Object {$_ -eq 'Y'} | Measure-Object).Count

      $RS3Count = ($RS3Enabled.ToCharArray() | Where-Object {$_ -eq 'Y'} | Measure-Object).Count

      $RS1Counts = ($RS1Status.ToCharArray() | Where-Object {$_ -eq 'U'} | Measure-Object).Count

      $RS2Counts = ($RS2Status.ToCharArray() | Where-Object {$_ -eq 'U'} | Measure-Object).Count

      $RS3Counts = ($RS3Status.ToCharArray() | Where-Object {$_ -eq 'U'} | Measure-Object).Count

       

       

       

       

      $RSEnabled = $RS1Count + $RS2Count + $RS3Count

      $RSUp = $RS1Counts + $RS2Counts + $RS3Counts

       

       

       

       

      Write-Host "Statistic.RSTotals: $RSTotal"

      Write-Host "Message.RSTotals: $VSName Virtual Service has $RSTotal Real Servers $RS1IP, $RS2IP & $RS3IP"

       

       

      Write-Host "Statistic.RSEnabled: $RSEnabled"

      Write-Host "Message.RSEnabled: $VSName Virtual Service has $RSEnabled Real Servers enabled"

       

       

      Write-Host "Statistic.RSUp: $RSUp"

       

       

       

       

      exit 0;