2 Replies Latest reply on Apr 6, 2015 10:00 AM by designerfx

    Powershell SWIS query issues




      I'm trying to get a SWIS query going from powershell. The goal at first is to basically read data via SWIS and I'm using

      $cred = New-Object System.Management.Automation.PSCredential ($login, $pass)

      $swis = Connect-Swis -host $hostname -cred $cred


      to pass my password to the script and connect, no problems there.

      However, what I missing to get the rest of the script to work? Here's the variable and statement I'm trying to execute:

      $selects = 'ComponentName, ComponentAvailability, StatusOrErrorDescription FROM Orion.APM.ComponentAlert WHERE ComponentName=@c'

      $swisquery = Get-SwisData -query SELECT $selects  @{c='Application Pools'}|ConvertTo-Json


      Yet I'm seeing the following powershell. I'm trying to figure out how to target only "application pools", first. What I get is:

      Get-SwisData : A positional parameter cannot be found that accepts argument 'ComponentName, ComponentAvailability, StatusOrErrorDescription FROM

      Orion.APM.ComponentAlert WHERE ComponentName=@c'.

      query.ps1:10 char:14

      + $swisquery = Get-SwisData -query SELECT $selects  @{c='Application Pools'}|Conve ...

      +              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          + CategoryInfo          : InvalidArgument: (:) [Get-SwisData], ParameterBindingException

          + FullyQualifiedErrorId : PositionalParameterNotFound,SwisPowerShell.GetSwisData

      10 char:14 is Get-SwisData.



      Now if I fix my own bad formatting and make a simpler query statement without syntax issues such as

      $swisquery = Get-SwisData -query SELECT 'ComponentName, ComponentAvailability, StatusOrErrorDescription FROM Orion.APM.ComponentAlert'|ConvertTo-Json

      I get the following error in powershell:

      Get-SwisData : Cannot bind parameter 'SwisConnection'. Cannot convert value "ComponentName, ComponentAvailability, StatusOrErrorDescription FROM 
      Orion.APM.ComponentAlert" to type "SolarWinds.InformationService.Contract2.InfoServiceProxy". Error: "Could not find endpoint element with name 
      'ComponentName, ComponentAvailability, StatusOrErrorDescription FROM Orion.APM.ComponentAlert' and contract 
      'SolarWinds.InformationService.Contract2.IStreamInformationService' in the ServiceModel client configuration section. This might be because no 
      configuration file was found for your application, or because no endpoint element matching this name could be found in the client element."


      So, is it a syntax thing? Is it the way I'm connecting and/or addressing values?