13 Replies Latest reply on Jul 14, 2017 11:10 AM by tdanner

    Error Updating Properties and Custom Properties of Nodes

    willelfakir

      Greetings,

       

       

      I am currently trying to automate the maintenance of the SWQL database using the ORION SDK, SwisSnappin and PowerORION Module for Powershell.

       

      I have been successful in deleting and adding nodes based on data imported from a .csv file.

       

      I keep getting the following error when trying to update node properties/custom properties using the Set-SwisObject cmdlet.

       

      Set-SwisObject : Invalid column name 'SNMPV3Username'.

      Invalid column name 'SNMPV3PrivMethod'.

      Invalid column name 'SNMPV3PrivKey'.

      Invalid column name 'SNMPV3AuthMethod'.

      Invalid column name 'SNMPV3AuthKey'.

      At C:\Users\welfakir\Documents\Powershell_Scripts\Add-Node\Update-Node.ps1:222 char:102

      + ...  @{IP=$node.IP} | Set-SwisObject -SwisConnection $swis -Properties @{

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

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

          + FullyQualifiedErrorId : SwisError,SwisPowerShell.SetSwisObject

       

      I am running SWQL Studio 2.2.54.0, NPM 12.1, SAM 6.4 (Both Trial as I cannot test on a production server) and PowerShell V5.

       

      On another note, when I create nodes I am using the sample found on git hub : OrionSDK/CRUD.AddNode.ps1 at master · solarwinds/OrionSDK · GitHub

       

      Are there other properties/pollers that need to be added upon creation for successful monitoring?

       

      Thanks,

       

      Will.

        • Re: Error Updating Properties and Custom Properties of Nodes
          tomas.vrabel

          Which properties are you updating when you receive this error?

          There is a bug in the product and update of some properties (e.g. community) throw similar exception.

          • Re: Error Updating Properties and Custom Properties of Nodes
            willelfakir

            I am also getting the following error when calling new-swisobject:

             

            New-SwisObject : Object reference not set to an instance of an object.

            At line:1 char:28

            + ... ewNodeUri = New-SwisObject $swis -EntityType "Orion.Nodes" -Propertie ...

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

                + CategoryInfo          : NotSpecified: (:) [New-SwisObject], NullReferenceException

                + FullyQualifiedErrorId : System.NullReferenceException,SwisPowerShell.NewSwisObject

             

            Thanks.

              • Re: Error Updating Properties and Custom Properties of Nodes
                bobmarley

                Just a guess but try updating only the Custom ones and not the Default ones and see if you get an error. Some of the custom ones appear to be 'locked down' in custom property editor. Such as Location which is typically derived from SNMP.

                • Re: Error Updating Properties and Custom Properties of Nodes
                  tomas.vrabel

                  Which properties are you setting for new node?

                  Could you please paste important part of your script here?

                    • Re: Error Updating Properties and Custom Properties of Nodes
                      willelfakir

                      FYI I am importing Props from a .csv file and running a for each where

                       

                      foreach($node in $csv)

                      {

                       

                      $newNodeProps = @{

                                      nodeID = $node.nodeID;

                                     #NODEID was the issue

                                      IPAddress = $node.IP; #Imported Ip Address from CSV file.

                                      EngineID = $node.EngineID; #Default EngineID

                                      Caption = $node.Caption; #Imported Caption from CSV file.

                                      #Location = $node.Location;

                                      # SNMP v2 specific

                                      ObjectSubType = $node.ObjectSubType;

                                      SNMPVersion = $node.SNMPVersion;

                           $NewNodeUri = New-SwisObject $swis -EntityType "Orion.Nodes" -Properties $NewNodeProps

                            $nodeProps = Get-SwisObject $swis -Uri $newNodeUri

                         

                                      # register specific pollers for the node

                                      Write-Verbose 'Registering Pollers'

                                      $poller = @{

                                      NetObject="N:"+$nodeProps["NodeID"];

                                      NetObjectType="N";

                                      NetObjectID=$nodeProps["NodeID"];

                                      }#$poller

                       

                       

                                      # Status

                                      $poller["PollerType"]="N.Status.ICMP.Native";

                                      $pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

                       

                       

                                      # Response time

                                      $poller["PollerType"]="N.ResponseTime.ICMP.Native";

                                      $pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

                       

                       

                                      # Details

                                      $poller["PollerType"]="N.Details.SNMP.Generic";

                                      $pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

                       

                       

                                      # Uptime

                                      $poller["PollerType"]="N.Uptime.SNMP.Generic";

                                      $pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

                       

                       

                                      # CPU

                                      $poller["PollerType"]="N.Cpu.SNMP.CiscoGen3";

                                      $pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

                       

                       

                                      # Memory

                                      $poller["PollerType"]="N.Memory.SNMP.CiscoGen3";

                                      $pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

                                        

                                     $customProps = @{

                                          ServerFunction = $node.ServerFunction;

                                          Environment = $node.EVNT;

                                          DomainName = $node.DomainName;

                              

                                     Get-SwisData $swis "SELECT Nodes.CustomProperties.Uri FROM Orion.Nodes where IP = @IP" @{IP = $node.IP} `

                                          |Set-SwisObject $swis  -Properties $customProps -erroraction continue

                       

                      }#foreach($node in $csv)

                  • Re: Error Updating Properties and Custom Properties of Nodes
                    capetocairo

                    I've spent some time working on something similar and although this doesn't include what you mentioned in your example you can probably take this and run with it. This script applies to custom properties, although I suppose you could tweak this to apply to generic properties. I have provided two different ways of doing this, so look at the script, choose which method best fits your needs and edit the script accordingly.

                     

                    #Intialize Swis-Snapin

                    Add-PSSNapin SwisSnapin 

                         

                    # Connect to SWIS

                     

                    $hostname = "Insert Orion IP"

                    $username = "Insert Username"

                    $password = "Insert Password" or you can use get-content Insert Path to Password Text Document | convertto-securestring 

                    $cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password 

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

                     

                    # This Next Section is Optional if You are Using Traditional SELECT Statements

                     

                    $filename = "Insert Path to Txt Doc with IP Addresses"

                    $ips = Get-Content $filename

                     

                    # prepare a custom property value

                     

                    $customProps = @{ 

                      Example 1=" "

                      Example 2=" "

                         

                    # Option 1 - If you are using the get-content $filename method

                     

                    $uris = Get-SwisData $swis "SELECT Nodes.CustomProperties.Uri FROM Orion.Nodes WHERE IP IN @ips" @{ ips = $ips }

                    $uris | Set-SwisObject $swis -Properties $customProps

                     

                    # Option 2 - If you are using a traditional SELECT statement

                     

                    $uris = Get-SwisData $swis "SELECT Nodes.CustomProperties.Uri FROM Orion.Nodes WHERE IP_Address LIKE 'Insert IP Address(s) Here'"

                    $uris | Set-SwisObject $swis -Properties $customProps