Showing results for 
Search instead for 
Did you mean: 
Create Post

Using PowerShell and the API to clean-up down volumes and find new volumes for those devices.

I don't know about yourselves, but we suffer with volumes reporting as down and Orion not picking up on their new instances automatically.

We think this is down to VM migrations or just configuration changes.

I used to go through a process of using SQL to find the dead volumes, then going to Node Manager, removing the down volumes and then running List Resources against the node to pick up on the new drive instances. This was a long winded and slow process, with an average of 140 down volumes found every week.

So I thought to myself, this needs some automation!


1. Find the down Volumes with a bit of SWQL

2. Remove these volumes using the API

3. Create URLs for each NodeID (found with down volumes) to open the 'List Resources' in a internet browser, with auto-refresh, so that you can manually select the volumes.

    As you can't do this via the API yet.

So here's a PowerShell script, that hopefully you can use to assist you.

Relies on having Chrome installed, to change from chrome.exe, delete the Stat-Process chrome.exe line and un-comment the iexplorer.exe line underneath.

The SELECT statement is limited to the first 10 down volumes, this limits the script to opening 10 List Resources at a time. You may want to increase or decrease this number.

Please ensure that you test this, somewhere safe, as I wouldn't want you to break anything.

# Description: SWIS PowerShell to find , then delete and then open the List Resources for that Node, so we can reselect the hard drives manually.

# Author: Richard Graham

# Date: 2019/02/06

# Notes: How-To make an encypted password file -

#Load SwisSnapin if required

if ( (Get-PSSnapin -Name SwisSnapin -ErrorAction SilentlyContinue) -eq $null )

      { Add-PSSnapin SwisSnapin }

#Alter these variables to suit your environment

$server = '<FQDN of Orion>'                                                # Your Orion server

$user ='SWISuser'                                                                # Orion username

$file = 'C:\Users\admin\encrypted-password.bin'                  # Orion user encrypted password file, see Notes for URL on how-to

$outfile = 'C:\Users\admin\resource_links.txt'                

#URL link

$resourcelink = 'http://' + $server + '/Orion/Nodes/ListResources.aspx?Nodes='

If ([System.IO.File]::Exists($outfile))

  { Remove-Item $outfile }

#Read encrypted file into $credential - see Notes for URL on how-to

$password = Get-Content $file | ConvertTo-SecureString

$creds = New-Object System.Management.Automation.PsCredential($user,$password)

#SWIS connection string

$swis = Connect-Swis -host $server -Credential $creds

#Get the down volume details

$results = Get-SwisData $swis "TOP 10 SELECT Uri, FullName, NodeID, VolumeID FROM Orion.Volumes WHERE Status = 2"

#$results = Get-SwisData $swis "SELECT Uri, FullName, NodeID, VolumeID FROM Orion.Volumes WHERE Status = 2"

#If no down Volumes then exit

Write-Host "There were" $results.Count "volumes reporting as down"

If ($result -eq $null) {exit(0)}

#Remove dead volumes and create resource URL file

ForEach ($result IN $results)


          #Write-Host $result.FullName "(NodeID :" $result.NodeID "VolumeID :" $result.VolumeID ") is down"

          #Delete Down VolumeIDs

          Write-Host "Deleting VolumeID:" $result.FullName

          Remove-SwisObject $swis -Uri $result.Uri

          #List resources for $result.NodeID adding all disk volumes (not memory, swap, etc)

          #This function is not yet available via the API, so we'll output URLs to file

          $link = $resourcelink + $result.NodeID + '&ForceRefresh=true'

          Out-File -Append -FilePath $outfile -InputObject $link


#Sort $outfile to be unique URLs

$unique = Get-Content $outfile | Sort | Get-Unique

Out-File -FilePath $outfile -InputObject $unique

#And then open Chrome tabs for each List Resources URL (make sure you are logged into Orion web GUI first)

$urls = Get-Content $outfile

ForEach ($url in $urls)

        { Start-Process "chrome.exe" $url

          #Start-Process 'C:\Program Files (x86)\Internet Explorer\iexplore.exe' $url



Very nice and inspired!

I believe you can add volumes using the API though, through a discovery, there are some threads in thwack about it and also in GitHub. Haven't tried them myself but they look promising.

How do you add volumes using the rest api?

how to add volumes to monitored resources via rest API &amp; curl

Discovery · solarwinds/OrionSDK Wiki · GitHub

We do something similar except we just use discoveries to automatically add in new volumes.  for us it gets the job done.

I think I need to be working on version 2 of this script

yaquaholic​ Super cool stuff here. Thank you for sharing!

Additionally, I've been meaning to reconfigure my scripts to use a better login method. Your document here has saved me a bunch of time.

Thank you,


Version history
Revision #:
1 of 1
Last update:
‎02-06-2019 11:41 AM
Updated by: