Adding ICMP nodes with Powershell

Hello Everyone, 

I've used a Powershell script for adding external nodes from a CSV file by rachelh found here and tried to adapt it for adding ICMP nodes. It works, but the nodes never poll. I suspect the problem relates to these:....

$poller["PollerType"]="N.Status.ICMP.Native";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

....but I don't know how to place these commands in this code:

$OrionServer="192.168.1.100"
$nodeListFile="C:\Users\Brent\Desktop\Thin-AP-List-2022-11-18.csv"

$creds=Get-Credential
$swis=Connect-Swis -Credential $creds -Hostname $OrionServer

ForEach ($ICMPnode in $nodes)
{
$ICMPNodeName=$ICMPnode.nodename
$ICMPIpAddress=$externalnode.ipa
Write-Host "Creating node:"$ICMPNodeName

# add the external node
$newNodeProps = @{Caption = $ICMPNodeName;Vendor="Aruba";IPAddress = $ICMPIpAddress;EngineID = 1;ObjectSubType = "ICMP";External=$FALSE;}
$newNodeUri = New-SwisObject $swis -EntityType "Orion.Nodes" -Properties $newNodeProps
$newNode = Get-SwisObject $swis -Uri $newNodeUri
}

Any help with be appreciated. Cheers! Brent

  • Something like this is what you'd end up with, and should work for this, essentially combining the two methods.

    You need to ensure you have proper formatting of the CSV file. The powershell below must have the headers "Caption", "IP_Address" and "Vendor" within the CSV. You could certainly adjust this as needed to include more or less data pulled in via columns in the csv.

    $OrionServer = "192.168.1.100"
    $creds = Get-Credential
    $swis = Connect-Swis -Credential $creds -Hostname $OrionServer
    $nodes = Import-Csv -Path "C:\Users\Brent\Desktop\Thin-AP-List-2022-11-18.csv"
    
    ForEach ($node in $nodes) {
    
    	$newNodeProps = $null
    	
    	$newNodeProps = @{
    	
    		IPAddress = $node.IP_Address;
    		Caption = $node.Caption;
    		EngineID = 1;
    
    		ObjectSubType = "ICMP";
    		DNS = "";
    		SysName = "";
    		
    		Vendor = $node.Vendor;
    		
    	}
    
    	$newNodeUri = New-SwisObject $swis -EntityType "Orion.Nodes" -Properties $newNodeProps
    	$nodeProps = Get-SwisObject $swis -Uri $newNodeUri
    
    	$poller = $null
    	
    	$poller = @{
    	
    		NetObject = "N:"+$nodeProps["NodeID"];
    		NetObjectType = "N";
    		NetObjectID = $nodeProps["NodeID"];
    		
    	}
    
    	# 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
    	
    	Write-Output("Node " + $node.NodeName + " has been added (" + $newNodeUri + ")")
    	
    }

  • Hello sum_giais, this works. I need to tweak a few things, like adding a loop checking to see if the node is already there, but I can handle that. Marked as 'verified answer,' many thanks! Brent

  • Thanks  for this thread, because I had taken the same script and tried to do the same thing with it (adding ICMP nodes) and had the same problem, and this thread fixed it all for me.

    Also thanks to  for the solution!

    Wish the old thread wasn't locked, as a note pointing to this thread would probably help a lot of people.

  • Hello Everyone,

    I know this is an older thread but I wanted to provide the script I am using to add ICMP nodes with polling. I'm giving credit to both RachelH from the forum post to bulk add external nodes and sum_gias from this thread for the coding fro polling. I am no Powershell expert but I was able to combine both codes to get ICMP bulk creation with catch error in RachelH's. Kinda a best of both worlds. Hope this helps someone. You only need to change the server IP and the csv file location. 

    #******* SET IP ADDRESS TO NPM SERVER YOU WANT TO CREATE NODES ON******
    $OrionServer="x.x.x.x"
    #******* Set path to CSV file containin node names *****
    # The CSV file should have THREE COLUMNS
    # The FIRST column should have a header cell called "NodeName"
    # The cells below are the names of the external nodes to create
    # The SECOND column should have a header cell called "IPA"
    # The cells below it should have the IP addresses associated with each of the nodes to create
    # The THIRD column should be called "Load"
    # The cells below this should contain a "Y" for each node you wish to create
    # (This allows you to have one big list but not create them all at the same time if you don't want to)
    $nodeListFile="FILE LOCATION HERE\ICMPNodesList.csv"
    #**** The script will ask for credentials.  Must have Node Manager rights*****
    $creds=Get-Credential
    $swis=Connect-Swis -Credential $creds -Hostname $OrionServer
    try {$nodes=Import-Csv $nodeListFile}
    catch {Write-Host "Could not import file.  Check path and type";Break}
    ForEach ($ICMPnode in $nodes)
    {
        $ICMPNodeName=$ICMPnode.nodename
        $ICMPIpAddress=$ICMPnode.ipa
        if ($ICMPnode.Load -eq 'Y')
        {
            $nodeExists = Get-SwisData $swis "SELECT Uri FROM Orion.Nodes WHERE Caption='$ICMPNodeName'"
            if (-not $nodeExists)
            {
                Write-Host "Creating node:"$ICMPNodeName
                # add the ICMP node
                $newNodeProps = @{Caption = $ICMPNodeName;Vendor="Placeholder";IPAddress = $ICMPIpAddress;EngineID = 1;ObjectSubType = "ICMP";External=$FALSE;}
                $newNodeUri = New-SwisObject $swis -EntityType "Orion.Nodes" -Properties $newNodeProps
                $newNode = Get-SwisObject $swis -Uri $newNodeUri
    	    $poller = $null
    	    $poller = @{
    		NetObject = "N:"+$newNode["NodeID"];
    		NetObjectType = "N";
    		NetObjectID = $newNode["NodeID"];
    	    }
    	    # 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	
                # WAIT 1 SECOND (To avoid overloading NPM server.  Can be removed)
                Start-Sleep -Milliseconds 1000  
            }
            else
            {
                Write-Host "Node already exists:"$ICMPNodeName  
            }
        }
        else
        {
            Write-host "Skipping node: $ICMPNodeName"
        }
    }