This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

add node using powershell

We are trying to automate the server build process so wanted to know how to add node in solarwinds using powershell for monitoring.

  • I cracked this one last week, not near my laptop for a few days but will try and post something early next week for you.

    It's all possible but took a bit of fiddling in our lab instance to get right.

  • Hi ,

    Can you share the idea with us, so that it will helpful to all.

  • Attached is an early version of my code that i used before our CMDB integration got involved emoticons_happy.png

    You'll find three functions at the top:

    Orion-AddNode - This creates either an ICMP or SNMP V2 Node

    Orion-SetStdDevicePollers - This assigns either the standard ICMP or SNMP Pollers, doesn't include any custom pollers and may be missing anything new

    Orion-SetHardwareHealthSensors - This assigns the HH sensors and you have to specify the hardware manufacturer for it to work.

    The rest of the script is the variables for the node your adding and the script itself.

    It assumes you have the SwisPowerShell module installed and loaded and your Swis connection is called $Swis.

    Good luck

    AddANodeInPowerShell.ps1
  • Is it for single node, right? How about multiple nodes?

    /MSARKAR

  • Correct this is for a single node but you can always use a foreach loop to go through a list,

    I have a CSV file with all the nodes and there details

    and then use this to loop through:

    $Nodes = import-csv -path "c:\scripts\book1.csv"

    Foreach ($Node in $Nodes)

    {

    $NewNode = Orion-AddNode -SwisConnection $Swis -NodeName $Node.NodeName -NodeIPAddress $Node.NodeIPAddress -PollingEngineID $Node.PollingEngineID -PollingMethod $Node.PollingMethod -SNMPV2Community $Node.SNMPV2Community

    $NodeProperties = Get-SwisObject $swis -Uri $NewNode

    $PollerAdds = Orion-SetStdDevicePollers -SwisConnection $Swis -NodeID  $NodeProperties.NodeID -PollingType $Node.PollingMethod

    $HHPolling = Orion-SetHardwareHealthSensors -SwisConnection $Swis -NodeID $NodeProperties.NodeID -Action Enable -Manufacturer $Node.NodeManufacturer

    $PollNodeID = $NodeProperties.OrionIdPrefix + $NodeProperties.NodeID

    $PollNow = Invoke-SwisVerb $Swis Orion.Nodes PollNow @($PollNodeID)

    }

    Both files are attached.

    attachments.zip
  • Hi,

    very new to this. Actually first day looking at it. I want to automated adding new firewalls to Solarwinds NCM.

    I've seen elsewhere that $swis is defined as :

                                     $swis = Connect-Swis -UserName admin -Password "" -Hostname 10.20.30.40

    I don't see $swis defined in your script.

    Also how do you add a node so that polling is snmpv3? All our firewalls are using snmpv3 now.

    I defined $swis in the script, edited the properties at the end (nodename, IP address, manufacturer) and ran it and got this error:

    New-SwisObject : The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9899819'.

    thanks

    Roger

  • > I don't see $swis defined in your script.

    Pretty much every code sample will need to define a connection to SWIS.  The exact details will depend on your environment (server, credentials).  There are details about how to do that here:

    PowerShell · solarwinds/OrionSDK Wiki · GitHub

    > Also how do you add a node so that polling is snmpv3?

    In the sample script, you'll notice these node properties being defined:

    $NewSNMPV2NodeProps = @{

                    IPAddress = $NodeIPAddress;

                    EngineID = $PollingEngineID;

                    Caption = $NodeName;

                    ObjectSubType =$PollingMethod;

                    Community = $SNMPV2Community;

                    SNMPVersion = "2";

                    DNS = "";

                    SysName = "";

                    }

    If you update the SNMPVersion property from "2" to "3", you'll change the protocol version.  You would probably also want to update a bunch of variable names that refer to SNMPV2 for clarity.

    > I defined $swis in the script, edited the properties at the end (nodename, IP address, manufacturer) and ran it and got this error:

    > New-SwisObject : The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9899819'.

    There are several possible causes for this error.  You might want to look through the articles here:

    https://support.solarwinds.com/SuccessCenter/s/global-search/%40uri#q=The%20socket%20connection%20was%20aborted&t=All&sort=relevancy

    You may also want to check the SWIS logs on the Orion server right after making a request.  Be default, those logs are at this location:

    C:\ProgramData\SolarWinds\InformationService\v3.0

  • Thanks for the reply.

    I'm good with the $swis variable.

    I was a bit premature in posting this. I did manage to get an SNMP3 node added.

    $NewSNMPNodeProps = @{

                    IPAddress = $NodeIPAddress;

                    EngineID = $PollingEngineID;

                    Caption = $NodeName;

    ObjectSubType = 'SNMP';               

                    SNMPVersion = "3";

    SNMPV3AuthKeyIsPwd = $false;

    SNMPV3AuthKey = $SNMPV3AuthKey;

    SNMPV3AuthMethod = $SNMPV3AuthMethod;

    SNMPV3PrivKeyIsPwd = $false;

    SNMPV3PrivKey = $SNMPV3PrivKey ;

    SNMPV3PrivMethod = $SNMPV3PrivMethod;

    SNMPV3Username = $SNMPV3Username;

    Location = 'CALI'

    Contact = 'Johnny'

                    DNS = "";

                    SysName = "";

                    }

    Only thing is, "SNMPV3PrivKeyIsPwd = $false" and "SNMPV3PrivKeyIsPwd = $false" ... are accepted but not actually set. I have to go into the GUI and uncheck the boxes. (Orion Platform 2018.4 HF3, NCM 7.9 ). Apparently it's a bug.

    Also the socket error seems to be the server running the powershell. I move it to another desktop and it work.

    thanks

  • I have been able to reproduce this behavior.  It's being tracked in internal issue CORE-13115.