-
Notifications
You must be signed in to change notification settings - Fork 20
/
CreateNodeCustomProperties.p1s
34 lines (28 loc) · 1.39 KB
/
CreateNodeCustomProperties.p1s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<#------------- CONNECT TO SWIS -------------#>
#define target host and credentials
$hostname = 'localhost'
#$user = "admin"
#$password = "password"
# create a connection to the SolarWinds API
#$swis = connect-swis -host $hostname -username $user -password $password -ignoresslerrors
$swis = Connect-Swis -Hostname $hostname -Trusted
<#------------- ACTUAL SCRIPT -------------#>
#create array of properties and their descriptions
$nodeproperties = @(
{Name = "Applications"; Description = "What software does this server support?"}
{Name = "ApplicationsRole"; Description = "What job does this server do within the application?"}
{Name = "AlertRecipient"; Description = "Who should be notified regarding issues on this node?"}
{Name = "Site"; Description = "What is the physical location of thise node?"}
{Name = "DeviceType"; Description = "What category of hardwareis this? Server, Firewall, Router, etc"}
)
foreach ( $prop in $nodeproperties ) {
$query = @"
select field from orion.customproperty where field = '$($prop.Name)'
"@
$check = Get-SwisData $swis $query
if ( $check.length -eq 0 ) {
"Creating Custom Property $($prop.Name)"
Invoke-SwisVerb $swis Orion.NodesCustomProperties CreateCustomProperty @("$($prop.Name)", "$($prop.Description)", "string", 100, $null, $null, $null, $null, $null, $null)
#confirm peoperty exists to end loop
}
}