Showing results for 
Search instead for 
Did you mean: 

PerfStack API PowerShell Module

My initial commit of a powershell module for querying the new PerfStack API

GitHub - StarkCaptain/solarwinds-perfstackapi: PowerShell Module that interfaces with the solarwinds...


You need to enable basic authentication on the api2 virtual directory in IIS on all web servers hosting the solarwinds website.

Basic Steps

  1. Suggested that you trust all certificates Enable-TrustAllCertificates
  2. Create a new Basic Authentication Credential $Cred = New-BasicAuthCreds -Username domain\username -Password P@ssw0rd
  3. Create a new SolarWinds Session $WebSession = New-SWSession -ServerName '' -Credential $Cred -ServerPort '6751'
  4. Read the Module Help Get-Help function-name

Basic Examples

Get the first 10 entities

$WebSession | Get-SWEntities

Returns all metrics for a specified entity

$WebSession | Get-SWEntityMetrics -EntityId 0_Orion.Nodes_2055

Gets the CPU MaxLoad for an entity for the last hour

$Start = (Get-Date).AddHours(-1)

$End = Get-Date

$WebSession | Get-SWMeasurement -EntityId 0_Orion.Nodes_2055 -MetricId Orion.CPULoad.MaxLoad -StartDate $Start -EndDate $End

Returns all relationships for a specified entity

$websession | Get-SWEntityRelationships -EntityId 0_Orion.Nodes_2055


I just realized that when I posted the comment below, I accidentally put it in your perfstack API post, not here in your Perfstack Powershell post... Duh.  Anyways, I'll paste it here so that it actually makes sense now:

Really great stuff man.   Impressive.

I'm trying to use your New-SWSession function and I keep getting the error of:

ERROR: New-SWSession : Exception setting "Name": "The 'Name'='Orion_IsSessionExp=' part of the cookie is invalid."

Looking at the code for it I think there is an error in it.  You create a new Cookie object, then you set the Name property of that Cookie object to "Id", but then in the very next line you set the same Name property of that Cookie Object to "/"…  Then, in the next line you once again change the Name of the Cookie object to the results of a replace on "ASP.NET_SessionId=" from the Session.Headers object with ''.  I'm trying to figure out what you were tying to do when you set that Cookie Name three times in a row.

Here's the section of code I'm referring to (Sorry I can't format it.  The Advanced Editor isn't available on replies for this kind of post for some reason…):

#Create a cookie in the Session Variable with the current SessionID

                $Cookie = New-Object System.Net.Cookie

                $Cookie.Name = "Id"

                $Cookie.Name = "/"

                #Best way I could figure out how to get the current SessionID from the Session; #Regex skills needed

                $Cookie.Name = $Session.Headers.'Set-Cookie'.Split(';')[0].Replace('ASP.NET_SessionId=','')

                $Cookie.Domain = $ServerName

Version history
Revision #:
1 of 1
Last update:
‎05-14-2017 07:41 PM
Updated by: