6 Replies Latest reply on Mar 16, 2017 9:26 AM by chrisagardner63

    PowerOrion - Works in IDE and No Where Else


      I have a script to add a Node and then Custom Properties.  I wrote the script in PowerShell IDE and when I run it in IDE it works.  When I save it and run it from a PowerShell window it fails.


      I am not running in x86, I am running as Adminstrator.


      I am getting the following errors-

      Get-SwisObject : Cannot bind argument to parameter 'SwisConnection' because it is null.

      At C:\windows\system32\windowspowershell\v1.0\Modules\PowerOrion\PowerOrion.psm1:226 char:45

      +                 $nodeProps = Get-SwisObject $swis -Uri $newNode

      +                                             ~~~~~

          + CategoryInfo          : InvalidData: (:) [Get-SwisObject], ParameterBindingValidationException

          + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,SwisPowerShell.GetSwisObject



      Cannot index into a null array.

      At C:\windows\system32\windowspowershell\v1.0\Modules\PowerOrion\PowerOrion.psm1:231 char:21

      +                     $nodeSettings = @{

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

          + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

          + FullyQualifiedErrorId : NullArray


      My Script:

      ##Decalre Variables

      Import-Module PowerOrion



      #SWIS Connection

      $Hostname = "corpmonap28rm39.safeautonet.net"




      $SNMPVersion = "SNMPv2"

      $CommunityString = "rad"



      #Server Information


      $ServerName = 'MyServerName'

      #Get DNS Name From IP

      $ServerIP = (resolve-dnsname -Type A $ServerName).IPAddress





      #SolarWinds Custom Properties

      $PatchGroupProd3 = 'PROD3'

      $EmailTo = "MyEmail"

      $EmailCC = ""

      $Environment = "Production"

      $Description = "TEST PowerShell"

      $Site = "HQ"



      $SWNodeProperties = @{



      Email_To = $EmailTo;

      Email_CC = $EmailCC;

      PatchGroup = $PatchGroupProd3;

      Environment = $Environment;

      SA_Description = $Description;

      Site = $Site;








      Write-Host $ServerName

      Write-Host $ServerIP



      $swis = Connect-Swis -Hostname $Hostname

      New-OrionNode -SwisConnection $swis -ObjectSubType $SNMPVersion -Community $CommunityString  -IPAddress $ServerIP -engineid "1"

      #New-OrionNode -SwisConnection $swis

      $URI = (get-orionnode -IPAddress $ServerIP -SwisConnection $swis).URi

      Write-Host $URI

      Set-SwisObject -Uri $URI -Properties @{ Caption = $ServerName  } -SwisConnection $swis

      Set-SwisObject $swis $URI/CustomProperties -Properties $SWNodeProperties

        • Re: PowerOrion - Works in IDE and No Where Else
          Michael Halpin

          Hi chrisagardner63


          I fixed a couple of bugs, can you download the latest version of the .psm1 and .psd1 from github, and replace those files on you disk and unload & reload the module.


          OrionSDK/Samples/PowerShell/PowerOrion at master · solarwinds/OrionSDK · GitHub

            • Re: PowerOrion - Works in IDE and No Where Else

              Hi Micheal -


              I downloaded the files and did as you requested, Removed and Imported the PowerOrion Module.  I am no longer getting the Swis-Connection errors, but now I am getting errors concerning get-orionnode or maybe my syntax is not correct?


              Get-help get-orionnode shows to use the -IPAddress switch which I am using and it appears that the error is stating that it is not correct?  I use the server IP Address to create the node.


              If I used the Node ID, I can see the properties of Node (its a windows server), but I need to use the IP Address.


              I pulled the following out of my script above to test with and I get the error using the -IPAddress switch,

              #SWIS Connection

                $Hostname = "corpmonap28rm39.safeautonet.net"

                $swis = Connect-Swis -Hostname $Hostname

                $ServerIP = ""

                Write-Host $ServerIP

                #$URI = (get-orionnode -IPAddress $ServerIP -SwisConnection $swis).URi'

                get-orionnode -IP $ServerIP -SwisConnection $swis

                 #Just tested with NodeID to make sure connection works and Node properties are available.

                #get-orionnode -NodeID 2237 -SwisConnection $swis



              The error is:

              Get-SwisObject : Input string was not in a correct format.

              At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PowerOrion\PowerOrion.psm1:564 char:18

              +     $nodeProps = Get-SwisObject $SwisConnection -Uri $uri

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

                  + CategoryInfo          : InvalidOperation: (:) [Get-SwisObject], FaultException`1

                  + FullyQualifiedErrorId : SwisError,SwisPowerShell.GetSwisObject



              Set-SwisObject : Cannot bind argument to parameter 'Uri' because it is null.

              At C:\temp\PSStudio2016\TestSW.ps1:48 char:44

              +     Set-SwisObject -SwisConnection $swis -Uri $URI -Properties @{ Cap ...

              +                                               ~~~~

                  + CategoryInfo          : InvalidData: (:) [Set-SwisObject], ParameterBindingValidationException

                  + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,SwisPowerShell.SetSwisObject



              Set-SwisObject : Invalid SWIS uri at character 17: Incomplete uri. Parser did not finish in End state, but instead was

              left in Scheme state

              Parameter name: uri

              At C:\temp\PSStudio2016\TestSW.ps1:51 char:2

              +     Set-SwisObject -SwisConnection $swis $URI/CustomProperties -Prope ...

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

                • Re: PowerOrion - Works in IDE and No Where Else

                  Wanted to update you, I could not get Get-OrionNode to work for me.  I rewrote that part of my script as below.  Its works as I expected it to.

                  Not sure if I am just not understanding Get-OrionNode or not.

                  I appreciate your work on PowerOrion, I am using this as part of a PowerShell GUI for my Junior Admins to ensure that servers get added to SolarWinds properly along with entering all of the necessary Custom Properties.


                  ##SolarWinds Create Node

                    New-OrionNode -SwisConnection $swis -ObjectSubType $SNMPVersion -Community $CommunityString -IPAddress $ServerIP -engineid "1"


                    ##SolarWinds Get Server URI

                    $NodeInfo = Get-SwisData $swis "SELECT NodeID, IPAddress, Sysname FROM Orion.Nodes where IPAddress = '$ServerIP'"

                    $NodeID = $NodeInfo.NodeID

                    Write-Host $NodeID

                    $URI = "swis://./Orion/Orion.Nodes/NodeID=$NodeId"


                    Write-Host $URI


                    ##SolarWinds Set Node Caption

                    Set-SwisObject -Uri $URI -Properties @{ Caption = $ServerName } -SwisConnection $swis


                    ##SolarWinds Set Node Custom Properties

                    Set-SwisObject -SwisConnection $swis $URI/CustomProperties -Properties $SWNodeProperties

              • Re: PowerOrion - Works in IDE and No Where Else
                Michael Halpin

                Thanks chrisagardner63.


                I'm currently looking at options on making this module a lot more robust, I'll definitely dig in to this in more detail when I get a bit of time. I really appreciate the feedback, let me know if you hit any more hurdles, once I get this updated I'll reply back, just in case you can test the other changes.