Hello all,
I have a script that add nodes to Orion but I would like to populate Make, Model, and serial. I removed all the important stuff, I would like $Serial to populate the custom array. Here is my code
#This sample script demonstrates how to add a new node using CRUD operations.
#
# Please update the hostname and credential setup to match your configuration, and
# information about the node you would like to add for monitoring.
# Connect to SWIS
$hostname = ""
$username = ""
$password = Read-Host "Enter Password" -AsSecureString
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
$swis = Connect-Swis -host $hostname -cred $cred
$ip = Read-Host "Enter the IP Address of Node"
# add a node
$newNodeProps = @{
IPAddress = $ip;
EngineID = 1;
# SNMP v2 specific
ObjectSubType = "SNMP";
SNMPVersion = 2;
Community = ""
# === default values ===
# EntityType = 'Orion.Nodes'
# Caption = ''
# DynamicIP = false
# PollInterval = 120
# RediscoveryInterval = 30
# StatCollection = 10
}
$newNodeUri = New-SwisObject $swis -EntityType "Orion.Nodes" -Properties $newNodeProps
$nodeProps = Get-SwisObject $swis -Uri $newNodeUri
$id =$nodeProps.NodeID
$serial = Get-SwisData $swis "SELECT ServiceTag FROM Orion.HardwareHealth.HardwareInfo WHERE NODEID= `'$id'"
# register specific pollers for the node
$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
# 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
$CustomProperties= @{
AppEnvironment="Production";
AppName="ESXi";
AppRole="Management";
Comments= "VSAN HOST D"
ConsoleAllowed="False";
enVision="False";
Make="Cisco Systems";
Model="UCSC-C240-M4Sx";
Rack="";
SerialNumber= ${serial};
Type="Server";
Site="MTXH";
}
# set the custom property
Set-SwisObject $swis -Uri ($newNodeUri + '/CustomProperties') -Properties $CustomProperties