-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathSwugPropertyExample.ps1
More file actions
36 lines (30 loc) · 1.16 KB
/
SwugPropertyExample.ps1
File metadata and controls
36 lines (30 loc) · 1.16 KB
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
35
36
#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 -------------#>
$query = @"
SELECT Nodes.customproperties.Uri, Nodes.Caption, nodes.customproperties.applicationsrole
FROM Orion.Nodes AS Nodes
where nodes.nodeid in
(select distinct nodeid
from orion.AssetInventory.Software
where name like 'Microsoft SQL Server%bit%')
and
(nodes.customproperties.applicationsrole is null
or nodes.customproperties.applicationsrole not like '%MSSQL database%')
"@
$Nodes = Get-SwisData $swis $query
foreach($Node in $Nodes)
{
if(!$Node.applicationsrole) {
$applicationsrole = 'MSSQL Database'
} else {
$applicationsrole = "$($Node.applicationsrole), MSSQL Database"
}
"Setting $($Node.Caption) ApplicationsRole to $applicationsrole"
Set-SwisObject -SwisConnection $swis -Uri $Node.uri -properties @{applicationsrole = $applicationsrole }
}