-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathRemoveApplications.ps1
More file actions
34 lines (26 loc) · 1.04 KB
/
RemoveApplications.ps1
File metadata and controls
34 lines (26 loc) · 1.04 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
<#------------- CONNECT TO SWIS -------------#>
# load the snappin if it's not already loaded (step 1)
if (!(Get-PSSnapin | Where-Object { $_.Name -eq "SwisSnapin" })) {
Add-PSSnapin "SwisSnapin"
}
#define target host and credentials
$hostname = 'yourserver'
# 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 -------------#>
# build the query in SWQL
$query = @"
select a.name, a.ApplicationID
from orion.apm.Application a
where a.node.caption like '%slwapps01%' and a.name = 'Microsoft IIS'
"@
# run the query and assign the results to the $applications array
$applications = Get-SwisData $swis $query
# iterate over the array
foreach ($app in $applications) {
# write out which application we're working with
"Working with application: $($app.name)..."
# delete the application
Invoke-SwisVerb $swis 'Orion.APM.Application' 'DeleteApplication' $app.applicationid
}