Quantcast
Channel: THWACK: Popular Discussions - Orion SDK
Viewing all 3719 articles
Browse latest View live

Powershell scripts to automatically unmanage\remanage a node using the Orion SDK

$
0
0

First, I'll share the script. Then, I'll explain why we need it and how it helps us in our environment.

To use the script you must have the Orion SDK installed on the monitored node.

 

Take the text below, paste in Powershell ISE and save it as a PS1.

------------------------------------ Start PS1 -----------------------------------------------------------------

 

# 2014-07-21 Node Unmanage script for SolarWinds SDK Powershell

# by Joe Dissmeyer | Thwack - @JoeDissmeyer | Twitter - @JoeDissmeyer | www.joedissmeyer.com

# This script will unmanage a single node in the Orion database. First, it finds the node number in the Orion database, then it will unmanage it for 99 years.

# This script assumes you are running it LOCALLY from an already managed node AND that the machine has the Orion SDK v1.9 installed on it.

# If the machine is not already managed in SolarWinds this script will fail without warning.

# Replace ORIONSERVERNAME with the appropriate values.

# ORIONSERVERNAME = Your Orion poller instance. (Ex. 'SOLARWINDS01.DOMAIN.LOCAL'). Single quotes are important.

 

# Load the SolarWinds Powershell snapin. Needed in order to execute the script. Requires the Orion SDK 1.9 installed on the machine this script is running from.

Add-PSSnapin SwisSnapin

 

 

# SolarWinds user name and password section. Create an Orion local account that only has node management rights. Enter the user name and password here.

$username = "SWnodemanagement"

$password = "MyP@44w0$d"

 

# This section allows the password to be embedded in this script. Without it the script will not work.

$secstr = New-Object -TypeName System.Security.SecureString

$password .ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$secstr

 

# The actual job

$ORIONSERVERNAME = 'SWServer1.domain.local'

$nodename = $env:COMPUTERNAME

 

$swis = Connect-Swis -Credential $cred -host $orionservername

$nodeid = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes WHERE SysName LIKE '$nodename%'"

$now =[DateTime ]:: Now

$later =$now.AddYears(99)

Invoke-SwisVerb $swis Orion.Nodes Unmanage @("N: $nodeid ", $now ,$later , "false")

 

------------------------------------ End PS1 -----------------------------------------------------------------

 

 

 

And now the Remanage script. Again, save as a .PS1 file.

------------------------------------ Start PS1 -----------------------------------------------------------------

 

# 2014-07-21 Node Remanage script for SolarWinds SDK Powershell

# by Joe Dissmeyer | Thwack - @JoeDissmeyer | Twitter - @JoeDissmeyer | www.joedissmeyer.com

# This script will remanage a single node in the Orion database.

# This script assumes you are running it LOCALLY from an already managed node AND that the machine has the Orion SDK v1.9 installed on it.

# If the machine is not already managed in SolarWinds this script will fail without warning.

# Replace ORIONSERVERNAME with the appropriate values.

# ORIONSERVERNAME = Your Orion poller instance. (Ex. 'SOLARWINDS01.DOMAIN.LOCAL'). Single quotes are important.

 

 

# Load the SolarWinds Powershell snapin. Needed in order to execute the script. Requires the Orion SDK 1.9 installed on the machine this script is running from.

Add-PSSnapin SwisSnapin

 

 

# SolarWinds user name and password section. Create an Orion local account that only has node management rights. Enter the user name and password here.

$username = "SWnodemanagement"

$password = "MyP@44w0%d"

 

 

# This section allows the password to be embedded in this script. Without it the script will not work.

$secstr = New-Object -TypeName System.Security.SecureString

$password .ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$secstr

 

 

# The actual job

$ORIONSERVERNAME = 'SWServer1.domain.local'

$nodename = $env:COMPUTERNAME

 

 

$swis = Connect-Swis -Credential $cred -host $orionservername

$nodeid = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes WHERE SysName LIKE '$nodename%'"

$now =[DateTime ]:: Now

$later =$now.AddYears(99)

Invoke-SwisVerb $swis Orion.Nodes Remanage @("N: $nodeid ", $now ,$later , "false")

 

------------------------------------ End PS1 -----------------------------------------------------------------

 

Explanation:

My company had a very unique need to monitor our enterprise Windows application that runs not only on standard desktop PCs, but also runs on mobile tablets connected to WiFi access points. These tablets run the standard Windows 7 Professional OS so it makes it easy to set up application monitoring in SolarWinds SAM for these machines. However, the problem comes at the end of the day when these tablets are turned off and placed in their charging docks for the night. As you can imagine, this creates an administrative nightmare (not to mention an email alert flood) in SolarWinds when this happens.

 

SolarWinds Orion NPM and SAM is designed to always keep an eye on a node or application that is entered in it's database. It is not designed to monitor an application or node only "part of the time" --- well, at least it isn't designed for this purpose out of the box. So instead, we have to create a workaround that will suit our needs. What we needed to do was figure out how to automatically "unmanage" these Windows tablet PCs in SolarWinds when they are shut down for the night, but also automatically "re-manage" them once they boot up. This is where the script comes into play.

 

The idea is to take the Unmanage script and apply it as a shut down script in Group Policy, then take the Remanage script and apply it as a boot up script in Group Policy.

Here is why this works for us:

The business is supposed to gracefully shut down the tablet by clicking Start > Shut down. If not, then an email alert triggers that informs us that the application is down on the machine.

If the tablet goes offline in the middle of the day for any reason, we will receive an email alert about that node.

When the machine is shut down properly, the node is automatically unmanaged in SolarWinds.

When the machine boots up and someone logs into the machine, the node is automatically remanaged in SolarWinds.

 

But here is an even better use for these scripts --- Scheduled Server Maintenance! How many times have we, server administrators, had to patch Windows Servers during scheduled maintenance hours? Normally you would have to go into SolarWinds and unmanage the node first BEFORE rebooting as not to trigger an email alert. Well with these scripts you wouldn't have to worry about that as much since this would be automatic.

 

Final notes:

Of course, this is just one way to go about auto-managing nodes in SolarWinds. There are some alternatives to doing this using the Orion SDK and Powershell which is to, instead, use the built-in .NET properties in Powershell 2.0 to access the Orion SQL database directly, find the node ID, and unmanage it in that manner. For those that are interested in how do to this without the Orion SDK, let me know and I'd be happy to elaborate.


Adding node custom properties does not work.

$
0
0

Hi, I am adding node with a custom properties but when it adds a node it does not fill the custom property part. Here is my script:

 

# This sample script demonstrates how to add a new node using CRUD operations.

#

# Please update the hostname and credential setup to match your configuration, and

# information about the node you would like to add for monitoring.

 

 

# Connect to SWIS

$hostname = "fmorn1pp01.fglcorporate.net"

$username = Read-Host -Prompt 'Enter user name'

$password = Read-Host -AsSecureString 'Enter password'

$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password

$swis = Connect-Swis -host $hostname -cred $cred

 

 

$ip = Read-Host -Prompt 'Input your IP address'

$Name = Read-Host -Prompt 'Input your server name'

 

 

# node configuration properties

function Show-Menu

{

     cls

     Write-Host "================ Select site ================"

 

 

     Write-Host "1: Press '1' Markham Head Office."

     Write-Host "2: Press '2' Calgary Head Office."

     Write-Host "3: Press '3' Calgary IT Office."

     Write-Host "4: Press '4' Calgary Colo."

     Write-Host "5: Press '5' Mississauga Head Office."

     Write-Host "6: Press '6' Laval Head Office."

     Write-Host "7: Press '7' Calgary Head Office."

     Write-Host "8: Press '8' FGL AJB."

     Write-Host "9: Press '9' MARKS AJB."

     Write-Host "10: Press '10' FGL WDC."

     Write-Host "11: Press '11' MARKS WDC."

     Write-Host "Q: Press 'Q' to quit."   

 

 

}

 

 

 

$selection = Read-Host "Please make a selection"

switch ($selection)

{

           '1' {

                $Site = 'Markham Head Office'

                'You chose option #1'

           } '2' {

                $Site = 'Calgary Head Office'

                'You chose option #2'

           } '3' {

                $Site = 'Calgary IT Office'

                'You chose option #3'

           }'4' {

                $Site = 'Calgary Colo'

                'You chose option #4'

           } '5' {

                $Site = 'Mississauga Head Office'

                'You chose option #5'

           } '6' {

                $Site = 'Laval Head Office'

                'You chose option #6'

           }'7' {

                $Site = 'Calgary Head Office'

                'You chose option #7'

           } '8' {

                $Site = 'FGL AJB'

                'You chose option #8'

           } '9' {

                $Site = 'MARKS AJB'

                'You chose option #9'

           } '10' {

                $Site = 'FGL WDC'

                'You chose option #10'

           } '11' {

                $Site = 'MARKS WDC'

                'You chose option #11'

 

 

           } 'q' { exit

           }

    

 

 

}

 

 

 

Cls

Write-Host "================ Select class ================"

    

     Write-Host "1: Press '1' A."

     Write-Host "2: Press '2' B."

     Write-Host "3: Press '3' C."

     Write-Host "4: Press '4' D."

     Write-Host "Q: Press 'Q' to quit.

 

 

 

 

$selection = Read-Host "Please make a selection"

switch ($selection)

{

           '1' {

                $Class = 'A'

                'You chose option #1'

           } '2' {

                $Class = 'B'

                'You chose option #2'

           } '3' {

                $Class = 'C'

                'You chose option #3'

           }'4' {

                $Class = 'D'

                'You chose option #4'

           } 'q' { exit

               

           }

}

 

 

 

 

Cls

Write-Host "================ Select environment ================"

    

     Write-Host "1: Press '1' Prod."

     Write-Host "2: Press '2' Pre-prod."

     Write-Host "3: Press '3' DEV."

     Write-Host "4: Press '4' QA."

     Write-Host "Q: Press 'Q' to quit.

 

 

 

   $selection = Read-Host "Please make a selection"

switch ($selection)

     {

           '1' {

                $Environment = 'Prod'

                'You chose option #1'

           } '2' {

                $Environment = 'Pre-prod'

                'You chose option #2'

           } '3' {

                $Environment = 'DEV'

                'You chose option #3'

           }'4' {

                $Environment = 'QA'

                'You chose option #4'

           } 'q' {

                exit

           }

     }

 

 

 

 

CLS

 

 

Write-Host "================ Select city ================"

    

     Write-Host "1: Press '1' Calgary."

     Write-Host "2: Press '2' Brampton."

     Write-Host "3: Press '3' Markham."

     Write-Host "4: Press '4' Mississauga."

     Write-Host "5: Press '5' Laval."

     Write-Host "6: Press '6' WDC."

     Write-Host "Q: Press 'Q' to quit."

 

 

    

 

   $selection = Read-Host "Please make a selection"

switch ($selection)

     {

           '1' {

                $City = 'Calgary'

                'You chose option #1'

           } '2' {

                $City = 'Brampton'

                'You chose option #2'

           } '3' {

                $City = 'Markham'

                'You chose option #3'

           }'4' {

                $City = 'Mississauga'

                'You chose option #4'

           } '5' {

                $City = 'Laval'

                'You chose option #5'

           }'6' {

                $City = 'WDC'

                'You chose option #6'

           } 'q' {

                exit

           }

     }

 

 

 

 

# add a node

$newNodeProps = @{

    IPAddress = $ip;

    NodeName = $Name

    EngineID = 17;

 

    # SNMP v2 specific

    ObjectSubType = "SNMP";

 

 

    SNMPVersion = 2;

 

 

    DNS = "$Name";

    SysName = "$Name";

   

    # === default values ===

 

 

    # EntityType = 'Orion.Nodes'

    # Caption = ''

    # DynamicIP = false

    # PollInterval = 120

    # RediscoveryInterval = 30

    # StatCollection = 10 

}

 

 

 

 

 

$newNodeUri = New-SwisObject $swis -EntityType "Orion.Nodes" -Properties $newNodeProps

$nodeProps = Get-SwisObject $swis -Uri $newNodeUri

 

 

# register specific pollers for the node

$poller = @{

    NetObject="N:"+$nodeProps["NodeID"];

    NetObjectType="N";

    NetObjectID=$nodeProps["NodeID"];

}

 

 

# prepare a custom property value

 

 

$customProps = @{

 

 

 

    CITY = "$City";

 

 

    CLASS_TYPE = "$Class";

 

 

    DEPARTMENT = "Infrastructure";

 

 

    DEVICE = "Server";

 

 

    OS_TYPE = "Windows";

 

 

    SITE = "$Site";

 

 

    VIRTUAL_SERVER = "Yes";

 

 

}

 

 

# build the node URI

$uri = "swis://fmorn1pp01/Orion/Orion.Nodes/NodeID=$($nodeProps.NodeID)/CustomProperties";

 

 

# set the custom property

Set-SwisObject $swis -Uri $uri -Properties $customProps

 

 

# Status

$poller["PollerType"]="N.Status.ICMP.Native";

$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

 

 

# Response time

$poller["PollerType"]="N.ResponseTime.ICMP.Native";

$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

 

 

# Details

$poller["PollerType"]="N.Details.SNMP.Generic";

$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

 

 

# Uptime

$poller["PollerType"]="N.Uptime.SNMP.Generic";

$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

 

 

# CPU

$poller["PollerType"]="N.Cpu.SNMP.HrProcessorLoad";

$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

 

 

# Network

$poller["PollerType"]="N.Topology_Layer3.SNMP.ipNetToMedia";

$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

 

 

# Storage_Memory

$poller["PollerType"]="N.Memory.SNMP.HrStorage";

$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

Set node custom properties using PowerShell Rest API

$
0
0

Hello,

 

I was able to add Orion node using the below per Re: SWIS REST/JSON API

$url = "https://server:17778/SolarWinds/InformationService/v3/Json/Create/Orion.Nodes"

 

Invoke-RestMethod -Uri $url -Method POST -Body $body -Credential $Credential -ContentType application/json

 

But when I attempted to set the custom properties for the node per the link PowerShell script to modify a NODE Custom Property via Rest API/JSON

using the code below,

 

$swisUri = "swis://server/Orion/Orion.Nodes/NodeID=$($NodeID)/CustomProperties"

$url = "https://server:17778/SolarWinds/InformationService/v3/Json/$swisUri"

 

$customProp = @{

    AssignmentGroup='Supportgroup';

    Category='Physical';

    NodeApplication='Application';

    Comments='Application server';

}

 

$body = ConverTo-Json $customProp

Invoke-RestMethod -Uri $url -Method POST -Body $body -Credential $Credential -ContentType application/json

 

I did not get any error, but the custom properties of the node were not set.

 

Per the link Re: SWIS REST/JSON API , there is a work-around using:

 

POST https://servername:17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.Reporting/ExecuteSQL

["Insert into NodesCustomProperties (NodeID) VALUES (13)"]

 

How can I construct the Insert statement in the json body above?

 

Thank you.

Receiving 403 Forbidden When Using REST API In C#

$
0
0

Receiving 403 Forbidden When Using REST API In C#

 

I was referred to the following C# example of using REST APIs Sample code: OrionSDK/Program.cs at master · solarwinds/OrionSDK · GitHub

 

This looked very promising and I have attempted to implement it for my process. However, all requests are failing with a 403 Forbidden error.

 

I have verified if I used invalid credentials I get a 401 unauthorized error so it appears to be authenticating my request, but I can't get results for a simple query operation.

 

I am basically using the code from the example but I am only calling the query action with the following simple query string and no arguments:

conststring query = @"SELECT nodeid, caption FROM Orion.Nodes";

 

I have output the JSON string created before it is passed to the request and it looks like this:

{"parameters":null,"query":"SELECT nodeid, caption FROM Orion.Nodes"}

 

Is there something wrong with the JSON or my query request?

Powershell scripts to automatically unmanage\remanage a node using the Orion SDK

$
0
0

First, I'll share the script. Then, I'll explain why we need it and how it helps us in our environment.

To use the script you must have the Orion SDK installed on the monitored node.

 

Take the text below, paste in Powershell ISE and save it as a PS1.

------------------------------------ Start PS1 -----------------------------------------------------------------

 

# 2014-07-21 Node Unmanage script for SolarWinds SDK Powershell

# by Joe Dissmeyer | Thwack - @JoeDissmeyer | Twitter - @JoeDissmeyer | www.joedissmeyer.com

# This script will unmanage a single node in the Orion database. First, it finds the node number in the Orion database, then it will unmanage it for 99 years.

# This script assumes you are running it LOCALLY from an already managed node AND that the machine has the Orion SDK v1.9 installed on it.

# If the machine is not already managed in SolarWinds this script will fail without warning.

# Replace ORIONSERVERNAME with the appropriate values.

# ORIONSERVERNAME = Your Orion poller instance. (Ex. 'SOLARWINDS01.DOMAIN.LOCAL'). Single quotes are important.

 

# Load the SolarWinds Powershell snapin. Needed in order to execute the script. Requires the Orion SDK 1.9 installed on the machine this script is running from.

Add-PSSnapin SwisSnapin

 

 

# SolarWinds user name and password section. Create an Orion local account that only has node management rights. Enter the user name and password here.

$username = "SWnodemanagement"

$password = "MyP@44w0$d"

 

# This section allows the password to be embedded in this script. Without it the script will not work.

$secstr = New-Object -TypeName System.Security.SecureString

$password .ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$secstr

 

# The actual job

$ORIONSERVERNAME = 'SWServer1.domain.local'

$nodename = $env:COMPUTERNAME

 

$swis = Connect-Swis -Credential $cred -host $orionservername

$nodeid = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes WHERE SysName LIKE '$nodename%'"

$now =[DateTime ]:: Now

$later =$now.AddYears(99)

Invoke-SwisVerb $swis Orion.Nodes Unmanage @("N: $nodeid ", $now ,$later , "false")

 

------------------------------------ End PS1 -----------------------------------------------------------------

 

 

 

And now the Remanage script. Again, save as a .PS1 file.

------------------------------------ Start PS1 -----------------------------------------------------------------

 

# 2014-07-21 Node Remanage script for SolarWinds SDK Powershell

# by Joe Dissmeyer | Thwack - @JoeDissmeyer | Twitter - @JoeDissmeyer | www.joedissmeyer.com

# This script will remanage a single node in the Orion database.

# This script assumes you are running it LOCALLY from an already managed node AND that the machine has the Orion SDK v1.9 installed on it.

# If the machine is not already managed in SolarWinds this script will fail without warning.

# Replace ORIONSERVERNAME with the appropriate values.

# ORIONSERVERNAME = Your Orion poller instance. (Ex. 'SOLARWINDS01.DOMAIN.LOCAL'). Single quotes are important.

 

 

# Load the SolarWinds Powershell snapin. Needed in order to execute the script. Requires the Orion SDK 1.9 installed on the machine this script is running from.

Add-PSSnapin SwisSnapin

 

 

# SolarWinds user name and password section. Create an Orion local account that only has node management rights. Enter the user name and password here.

$username = "SWnodemanagement"

$password = "MyP@44w0%d"

 

 

# This section allows the password to be embedded in this script. Without it the script will not work.

$secstr = New-Object -TypeName System.Security.SecureString

$password .ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$secstr

 

 

# The actual job

$ORIONSERVERNAME = 'SWServer1.domain.local'

$nodename = $env:COMPUTERNAME

 

 

$swis = Connect-Swis -Credential $cred -host $orionservername

$nodeid = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes WHERE SysName LIKE '$nodename%'"

$now =[DateTime ]:: Now

$later =$now.AddYears(99)

Invoke-SwisVerb $swis Orion.Nodes Remanage @("N: $nodeid ", $now ,$later , "false")

 

------------------------------------ End PS1 -----------------------------------------------------------------

 

Explanation:

My company had a very unique need to monitor our enterprise Windows application that runs not only on standard desktop PCs, but also runs on mobile tablets connected to WiFi access points. These tablets run the standard Windows 7 Professional OS so it makes it easy to set up application monitoring in SolarWinds SAM for these machines. However, the problem comes at the end of the day when these tablets are turned off and placed in their charging docks for the night. As you can imagine, this creates an administrative nightmare (not to mention an email alert flood) in SolarWinds when this happens.

 

SolarWinds Orion NPM and SAM is designed to always keep an eye on a node or application that is entered in it's database. It is not designed to monitor an application or node only "part of the time" --- well, at least it isn't designed for this purpose out of the box. So instead, we have to create a workaround that will suit our needs. What we needed to do was figure out how to automatically "unmanage" these Windows tablet PCs in SolarWinds when they are shut down for the night, but also automatically "re-manage" them once they boot up. This is where the script comes into play.

 

The idea is to take the Unmanage script and apply it as a shut down script in Group Policy, then take the Remanage script and apply it as a boot up script in Group Policy.

Here is why this works for us:

The business is supposed to gracefully shut down the tablet by clicking Start > Shut down. If not, then an email alert triggers that informs us that the application is down on the machine.

If the tablet goes offline in the middle of the day for any reason, we will receive an email alert about that node.

When the machine is shut down properly, the node is automatically unmanaged in SolarWinds.

When the machine boots up and someone logs into the machine, the node is automatically remanaged in SolarWinds.

 

But here is an even better use for these scripts --- Scheduled Server Maintenance! How many times have we, server administrators, had to patch Windows Servers during scheduled maintenance hours? Normally you would have to go into SolarWinds and unmanage the node first BEFORE rebooting as not to trigger an email alert. Well with these scripts you wouldn't have to worry about that as much since this would be automatic.

 

Final notes:

Of course, this is just one way to go about auto-managing nodes in SolarWinds. There are some alternatives to doing this using the Orion SDK and Powershell which is to, instead, use the built-in .NET properties in Powershell 2.0 to access the Orion SQL database directly, find the node ID, and unmanage it in that manner. For those that are interested in how do to this without the Orion SDK, let me know and I'd be happy to elaborate.

Add/Update Orion node with Powershell Rest API using Json data type

$
0
0

Hello,

 

I would like to add/update the Orion node with PowerShell Rest API using Json data type.  I want to know if any one has any sample code that I can look at.

 

Thank you in advance.

 

CluM09

Query nodes based on custom property

$
0
0

Hello,

 

Is there any way to query the Orion nodes with all the custom properties?

 

Thanks.

CluM09

Receiving 403 Forbidden When Using REST API In C#

$
0
0

Receiving 403 Forbidden When Using REST API In C#

 

I was referred to the following C# example of using REST APIs Sample code: OrionSDK/Program.cs at master · solarwinds/OrionSDK · GitHub

 

This looked very promising and I have attempted to implement it for my process. However, all requests are failing with a 403 Forbidden error.

 

I have verified if I used invalid credentials I get a 401 unauthorized error so it appears to be authenticating my request, but I can't get results for a simple query operation.

 

I am basically using the code from the example but I am only calling the query action with the following simple query string and no arguments:

conststring query = @"SELECT nodeid, caption FROM Orion.Nodes";

 

I have output the JSON string created before it is passed to the request and it looks like this:

{"parameters":null,"query":"SELECT nodeid, caption FROM Orion.Nodes"}

 

Is there something wrong with the JSON or my query request?


How do I use PowerShell To Add Graphs To A View?

$
0
0

I am looking for a way to add resources to a view, via PowerShell.

Currently, using SWQL Studio to invoke "AddResourceToView", I can supply the 3 arguments (viewId, config, & moveColliding), and successfully add a new resource to a view.

I want to put that workflow into a PowerShell script, allowing me to easily change the view and SWQL query results.


This is what I have, so far:

Here is the standard connection part of the script:

# Connections, and stuff

$ErrorActionPreference = 'Stop'

# Set up the hostname, username, and password for the source system
$hostname = "meow";
#$password1 = New-Object System.Security.SecureString  #"" | ConvertTo-SecureString -asPlainText -Force
$username = "arf"
$password = "moo" | ConvertTo-SecureString -asPlainText -Force

# Load the SwisSnapin if not already loaded
if (!(Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {
    Add-PSSnapin "SwisSnapin"
}

# Connect to the source system
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
$swis = Connect-Swis -Credential $credential -Hostname $hostname

function IsEmpty($str) {
    $str -eq $null -or $str -eq '' -or $str.GetType() -eq [DBNull]
}

 

 

Here is the part where I set the arguments for the verb jammy-thing:

# Verb argument 1

# The "AddResourceToView" verb requires 3 arguments to successfully add a new resource to a view. (I think it only requires the first 2)
# The "AddResourceToView" verb requires "viewId", "config", & "moveColliding", in this order.
# Verb argument 1
# This is the viewID of the page/view on which to add the new graph(s).
$viewId="211"
#$viewId=[int32]211

 

 

# Verb argument 2 (I am not actually using the "\" character before "<resource...", but this post seems to keep removing the rest of the lines for some reason.

# The "config" argument should be a string containing xml like this:
# https://thwack.solarwinds.com/message/344536#344536
# This is the SWQL query that will return the "config" portion, having filled in the Node/Interface data in the appropriate places.
#$configs= Get-SwisData $swis "SELECT '\<resource name="Custom Object Resource" file="/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx" column="1" position="1" title="" subtitle=""><properties><property name="AutoHide" value="0"/><property name="Calculate95thPercentile" value="0"/><property name="CalculateSum" value="0"/><property name="CalculateTrendLine" value="0"/><property name="ChartDateSpan" value="2"/><property name="ChartInitialZoom" value="24h"/><property name="ChartName" value="AvgBps-Line"/><property name="ChartSubtitle" value="${ZoomRange}"/><property name="ChartTitle" value="${Caption}"/><property name="CustomObjectMode" value="0"/><property name="EmbeddedObjectResource" value="/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;"/><property name="EntityName" value="Orion.NPM.Interfaces"/><property name="FilterEntities" value="False"/><property name="HideThreshold" value="0"/><property name="Initialized" value="True"/><property name="NetObjectID" value="I:'+TOSTRING(n.Interfaces.InterfaceID)+'"/><property name="NetObjectPrefix" value="I"/><property name="NumberOfSeriesToShow" value="0"/><property name="ObjectUri" value="'+n.Interfaces.Uri+'"/><property name="SampleSize" value="5"/><property name="SelectedEntities" value="'+TOSTRING(n.Interfaces.InterfaceID)+'"/><property name="ShowTitle" value="1"/><property name="SubTitle" value=""/><property name="Title" value=""/></properties></resource>' AS [AvgBps-Line_configCol-1] FROM Orion.Nodes AS n WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'"
$configs= [String[]](Get-SwisData $swis "SELECT '\<resource name=""Custom Object Resource"" file=""/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx"" column=""1"" position=""1"" title="""" subtitle=""""><properties><property name=""AutoHide"" value=""0""/><property name=""Calculate95thPercentile"" value=""0""/><property name=""CalculateSum"" value=""0""/><property name=""CalculateTrendLine"" value=""0""/><property name=""ChartDateSpan"" value=""2""/><property name=""ChartInitialZoom"" value=""24h""/><property name=""ChartName"" value=""AvgBps-Line""/><property name=""ChartSubtitle"" value=""${ZoomRange}""/><property name=""ChartTitle"" value=""${Caption}""/><property name=""CustomObjectMode"" value=""0""/><property name=""EmbeddedObjectResource"" value=""/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;""/><property name=""EntityName"" value=""Orion.NPM.Interfaces""/><property name=""FilterEntities"" value=""False""/><property name=""HideThreshold"" value=""0""/><property name=""Initialized"" value=""True""/><property name=""NetObjectID"" value=""I:'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""NetObjectPrefix"" value=""I""/><property name=""NumberOfSeriesToShow"" value=""0""/><property name=""ObjectUri"" value=""'+n.Interfaces.Uri+'""/><property name=""SampleSize"" value=""5""/><property name=""SelectedEntities"" value=""'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""ShowTitle"" value=""1""/><property name=""SubTitle"" value=""""/><property name=""Title"" value=""""/></properties></resource>' AS [meow] FROM Orion.Nodes AS n WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'")
#$configs= [String](Get-SwisData $swis "SELECT '\<resource name=""Custom Object Resource"" file=""/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx"" column=""1"" position=""1"" title="""" subtitle=""""><properties><property name=""AutoHide"" value=""0""/><property name=""Calculate95thPercentile"" value=""0""/><property name=""CalculateSum"" value=""0""/><property name=""CalculateTrendLine"" value=""0""/><property name=""ChartDateSpan"" value=""2""/><property name=""ChartInitialZoom"" value=""24h""/><property name=""ChartName"" value=""AvgBps-Line""/><property name=""ChartSubtitle"" value=""${ZoomRange}""/><property name=""ChartTitle"" value=""${Caption}""/><property name=""CustomObjectMode"" value=""0""/><property name=""EmbeddedObjectResource"" value=""/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;""/><property name=""EntityName"" value=""Orion.NPM.Interfaces""/><property name=""FilterEntities"" value=""False""/><property name=""HideThreshold"" value=""0""/><property name=""Initialized"" value=""True""/><property name=""NetObjectID"" value=""I:'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""NetObjectPrefix"" value=""I""/><property name=""NumberOfSeriesToShow"" value=""0""/><property name=""ObjectUri"" value=""'+n.Interfaces.Uri+'""/><property name=""SampleSize"" value=""5""/><property name=""SelectedEntities"" value=""'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""ShowTitle"" value=""1""/><property name=""SubTitle"" value=""""/><property name=""Title"" value=""""/></properties></resource>' AS [meow] FROM Orion.Nodes AS n WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'")
#$configs= Get-SwisData $swis "SELECT '\<resource name=""Custom Object Resource"" file=""/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx"" column=""1"" position=""1"" title="""" subtitle=""""><properties><property name=""AutoHide"" value=""0""/><property name=""Calculate95thPercentile"" value=""0""/><property name=""CalculateSum"" value=""0""/><property name=""CalculateTrendLine"" value=""0""/><property name=""ChartDateSpan"" value=""2""/><property name=""ChartInitialZoom"" value=""24h""/><property name=""ChartName"" value=""AvgBps-Line""/><property name=""ChartSubtitle"" value=""${ZoomRange}""/><property name=""ChartTitle"" value=""${Caption}""/><property name=""CustomObjectMode"" value=""0""/><property name=""EmbeddedObjectResource"" value=""/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;""/><property name=""EntityName"" value=""Orion.NPM.Interfaces""/><property name=""FilterEntities"" value=""False""/><property name=""HideThreshold"" value=""0""/><property name=""Initialized"" value=""True""/><property name=""NetObjectID"" value=""I:'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""NetObjectPrefix"" value=""I""/><property name=""NumberOfSeriesToShow"" value=""0""/><property name=""ObjectUri"" value=""'+n.Interfaces.Uri+'""/><property name=""SampleSize"" value=""5""/><property name=""SelectedEntities"" value=""'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""ShowTitle"" value=""1""/><property name=""SubTitle"" value=""""/><property name=""Title"" value=""""/></properties></resource>' AS [meow] FROM Orion.Nodes AS n WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'"

 

 

# Verb argument 3

# This is the 3rd, and final, verb argument required to create the new resource on the page.
# Setting this to "True" will bump down any resource already configured to the same column/row as the resource being added.
#$moveColliding="True"
#$moveColliding=[boolean]"True"

 

# And here is the part where I think it is supposed to loop through each result, from the SWQL query in argument 2, and add a new resource to the view from argument 1

foreach ($config in $configs) {    # config.meow = the data from the SWQL query?
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @("$viewId", @{config=$config.meow})
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @("$viewId", @{config="$config.meow"})    Invoke-SwisVerb $swis Orion.Views AddResourceToView @("$viewId", $config.meow)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @($viewId, $configs)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @($viewId, $configs, $moveColliding)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @{viewId=$viewId, $configs, $moveColliding}
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@{viewId=$viewId, $configs, $moveColliding})
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@($viewId, $configs, $moveColliding))
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@($viewId, $config.meow, $moveColliding))
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @( ,@($viewId, $config.meow, $moveColliding))
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @( ,@($viewId, @{config = $config.meow}, $moveColliding))
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @($viewId, @{config = $config.meow}, $moveColliding)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @("$viewId", @{config = $config.meow}, "$moveColliding")
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@($viewId), @{config = $config.meow}, $moveColliding)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@(211), @{config = $config.meow}, $moveColliding)
}

 

 

 

As you can see by the commented lines above, I have tried several different ways. I have searched through numerous different Thwack posts, related to SDK, API, PowerShell, Invoke-SwisVerb, etc., and have tried to apply advice from those various posts, with no success.

 

Most of the different ways I have failed ended with actual error messages in PowerShell ISE, as seen below:

Invoke-SwisVerb : Verb Orion.Views.AddResourceToView cannot unpackage parameter 1 of type System.String
Invoke-SwisVerb : Object of type 'System.String[]' cannot be converted to type 'System.String'.
Invoke-SwisVerb : There are multiple root elements. Line 1, position 1544.
Get-SwisData : Cannot bind parameter 'Parameters'. Cannot convert the "SELECT '
Invoke-SwisVerb : Type 'System.Management.Automation.PSObject' with data contract name 'PSObject:http://schemas.datacontract.org/2004/07/System.Management.Automation' is not expected. 
Invoke-SwisVerb : There was an error generating the XML document.

 

 

While I have virtually no idea what I am doing here (that's why they make labs, right?), I was able to get, what I think, is a valid error message, as in the script ran, but each attempt to add the new resource failed. (As opposed to the script itself failing)

PS C:\Users\Administrator> Z:\powershell script examples\DEV_Add_Graph_To_View.ps1


xmlns                                                                          #text
-----                                                                          -----
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false

 

 

 

 

This is the SWQL query I use to build the config file, which works fine when I copy/paste the results from the SWQL query into the invoke page within SWQL Studio, but not PowerShell.

SELECT
'<resource name="Custom Object Resource" file="/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx" column="1" position="1" title="" subtitle=""><properties><property name="AutoHide" value="0"/><property name="Calculate95thPercentile" value="0"/><property name="CalculateSum" value="0"/><property name="CalculateTrendLine" value="0"/><property name="ChartDateSpan" value="2"/><property name="ChartInitialZoom" value="24h"/><property name="ChartName" value="AvgBps-Line"/><property name="ChartSubtitle" value="${ZoomRange}"/><property name="ChartTitle" value="${Caption}"/><property name="CustomObjectMode" value="0"/><property name="EmbeddedObjectResource" value="/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;"/><property name="EntityName" value="Orion.NPM.Interfaces"/><property name="FilterEntities" value="False"/><property name="HideThreshold" value="0"/><property name="Initialized" value="True"/><property name="NetObjectID" value="I:'+TOSTRING(n.Interfaces.InterfaceID)+'"/><property name="NetObjectPrefix" value="I"/><property name="NumberOfSeriesToShow" value="0"/><property name="ObjectUri" value="'+n.Interfaces.Uri+'"/><property name="SampleSize" value="5"/><property name="SelectedEntities" value="'+TOSTRING(n.Interfaces.InterfaceID)+'"/><property name="ShowTitle" value="1"/><property name="SubTitle" value=""/><property name="Title" value=""/></properties></resource>' AS [meow]
FROM Orion.Nodes AS n
WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'

 

 

 

I am hoping someone can point me in the direction closest to the answer I seek.

 

 

Thank you,

 

-Will

Modify Volume Custom Property

$
0
0

I want to be able to Modify the value of a Volume Custom Property but can not seem to find the correct SWIS VERB syntax.

 

# Get the Node information I need

$NODE = Get-SwisData $swis "SELECT NodeID,Caption,SysName,DNS FROM Orion.Nodes WHERE DNS=@DNSFQDN" @{ DNSFQDN = $DNSFQDN }

$NODEID = $NODE.NodeID

#Using the NodeID QUery the volume to get the Custom Property and Everything else to check it works.

$OrionResponses = Get-SwisData $swis "SELECT Volumes.CustomProperties.BitLocker_Enabled, [AncestorDetailsUrls],[AncestorDisplayNames],[Caption],[Description],[DetailsUrl],[DetailsUrl],[DeviceId],[DiskQueueLength],[DiskReads],[DiskSerialNumber],[DiskTransfer],[DiskWrites],[DisplayName],[DisplayName],[FullName],[Icon],[Image],[Index],[InstanceSiteId],[InstanceType],[InterfaceType],[LastSync],[MinutesSinceLastSync],[NextPoll],[NextRediscovery],[NodeID],[OrionIdColumn],[OrionIdPrefix],[PollInterval],[RediscoveryInterval],[Responding],[SCSIControllerId],[SCSILunId],[SCSIPortId],[SCSIPortOffset],[SCSITargetId],[Size],[SkippedPollingCycles],[StatCollection],[Status],[Status],[StatusDescription],[StatusIcon],[StatusIconHint],[StatusLED],[StatusLED],[TotalDiskIOPS],[Type],[UnManaged],[UnManageFrom],[UnManageUntil],[Uri],[VolumeAllocationFailuresThisHour],[VolumeAllocationFailuresToday],[VolumeDescription],[VolumeID],[VolumeIndex],[VolumePercentAvailable],[VolumePercentUsed],[VolumeResponding],[VolumeSize],[VolumeSpaceAvailable],[VolumeSpaceAvailableExp],[VolumeSpaceUsed],[VolumeType],[VolumeTypeIcon],[VolumeTypeID]

FROM Orion.Volumes WHERE NodeID=@nodeis AND DeviceID=@deviceIs" @{ nodeis = $NodeID; deviceIs = $DeviceID }

# Uncomment the line below for troubleshooting and to see what is returned

#$OrionResponses

# Construct the modify array elements

$propertyname = "Bitlocker_Enabled"

Invoke-SwisVerb $swis Orion.Volumes.CustomProperties ModifyCustomProperty @($propertyName,'true')

 

The result of running the script and this particular section is:

 

BitLocker_Enabled                : True                                                                                                                                    

AncestorDetailsUrls              : {/Orion/NetPerfMon/VolumeDetails.aspx?NetObject=V:6238, /Orion/NetPerfMon/NodeDetails.aspx?NetObject=N:2897}                            

AncestorDisplayNames             : {E:\ Label:SWINstalls 4C3B9FA0, MON-NETMON2}                                                                                            

Caption                          : E:\ Label:SWINstalls 4C3B9FA0                                                                                                           

Description                      : Fixed Disk                                                                                                                              

DetailsUrl                       : /Orion/NetPerfMon/VolumeDetails.aspx?NetObject=V:6238                                                                                   

DetailsUrl1                      : /Orion/NetPerfMon/VolumeDetails.aspx?NetObject=V:6238                                                                                   

DeviceId                         : E:                                                                                                                                      

DiskQueueLength                  : 0                                                                                                                                       

DiskReads                        : 0                                                                                                                                       

DiskSerialNumber                 :                                                                                                                                         

DiskTransfer                     : 0                                                                                                                                       

DiskWrites                       : 0                                                                                                                                       

DisplayName                      : E:\ Label:SWINstalls 4C3B9FA0                                                                                                           

DisplayName1                     : E:\ Label:SWINstalls 4C3B9FA0                                                                                                           

FullName                         : MON-NETMON2-E:\ Label:SWINstalls 4C3B9FA0                                                                                               

Icon                             : FixedDisk.gif                                                                                                                           

Image                            :                                                                                                                                         

Index                            : 7                                                                                                                                       

InstanceSiteId                   : 0                                                                                                                                       

InstanceType                     : Orion.Volumes                                                                                                                           

InterfaceType                    :                                                                                                                                         

LastSync                         : 3/2/2018 21:53:16                                                                                                                       

MinutesSinceLastSync             : 0                                                                                                                                       

NextPoll                         : 3/2/2018 21:55:07                                                                                                                       

NextRediscovery                  : 3/2/2018 21:53:44                                                                                                                       

NodeID                           : 2897                                                                                                                                    

OrionIdColumn                    : VolumeID                                                                                                                                

OrionIdPrefix                    : V:                                                                                                                                      

PollInterval                     : 120                                                                                                                                     

RediscoveryInterval              : 30                                                                                                                                      

Responding                       : Y                                                                                                                                       

SCSIControllerId                 :                                                                                                                                         

SCSILunId                        :                                                                                                                                         

SCSIPortId                       :                                                                                                                                         

SCSIPortOffset                   :                                                                                                                                         

SCSITargetId                     :                                                                                                                                         

Size                             : 42946523136                                                                                                                             

SkippedPollingCycles             : 0                                                                                                                                       

StatCollection                   : 15                                                                                                                                      

Status                           : 1                                                                                                                                       

Status1                          : 1                                                                                                                                       

StatusDescription                : Up                                                                                                                                      

StatusIcon                       : Up.gif                                                                                                                                  

StatusIconHint                   :                                                                                                                                         

StatusLED                        : Up.gif                                                                                                                                  

StatusLED1                       : Up.gif                                                                                                                                  

TotalDiskIOPS                    : 0                                                                                                                                       

Type                             : Fixed Disk                                                                                                                              

UnManaged                        : False                                                                                                                                   

UnManageFrom                     :                                                                                                                                         

UnManageUntil                    :                                                                                                                                         

Uri                              : swis://MON-NetMon.stanleygroup.com/Orion/Orion.Nodes/NodeID=2897/Volumes/VolumeID=6238                                                  

VolumeAllocationFailuresThisHour : 0                                                                                                                                       

VolumeAllocationFailuresToday    : 0                                                                                                                                       

VolumeDescription                : E:\ Label:SWINstalls  Serial Number 4C3B9FA0                                                                                            

VolumeID                         : 6238                                                                                                                                    

VolumeIndex                      : 7                                                                                                                                       

VolumePercentAvailable           : 76.92691                                                                                                                                

VolumePercentUsed                : 23.07309                                                                                                                                

VolumeResponding                 : Y                                                                                                                                       

VolumeSize                       : 42946523136                                                                                                                             

VolumeSpaceAvailable             : 33037434880                                                                                                                             

VolumeSpaceAvailableExp          : 33037434880                                                                                                                             

VolumeSpaceUsed                  : 9909088256                                                                                                                              

VolumeType                       : Fixed Disk                                                                                                                              

VolumeTypeIcon                   : FixedDisk.gif                                                                                                                           

VolumeTypeID                     : 4                                                                                                                                       

                                                                                                                                                                           

Invoke-SwisVerb : Verb Orion.Volumes.CustomProperties.ModifyCustomProperty: Not found                                                                                      

At C:\Users\8304\Documents\SAPIEN\PowerShell Studio\Files\Bitlocker-SAM.ps1:115 char:3                                                                                     

+         Invoke-SwisVerb $swis Orion.Volumes.CustomProperties ModifyCu ...                                                                                                

+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                    

    + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1                                                                                    

    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb             

 

I tried mimicking the syntax examples for modifying the node custom properties using the Volumes. But is obviously not working. Any insights into the correct syntax would be appreciated.                                                                                        

Get-SwisObject : An error occurred when verifying security for the message.

$
0
0


I am trying to connect to SolarWinds server from a different server and run a powershell script.  My ultimate goal is mark an IP address as available.  I can get the connection established, but as soon as I do a Get-SwisObject I get a security message.

 

Get-SwisObject : An error occurred when verifying security for the message.

 

If I put in a bogas password, I get the same message, so I guess I am not convinced that I am actually getting connected to my solarwinds server.

 

Here is my script:

 

If (!(Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {
    Add-PSSnapin "SwisSnapin"
}

 

$hostname = "solar.mycompany.com"
$username="admin"
$password="1234567"

 

$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))

 

#Connect to the System
$target = Connect-Swis -v2 -Credential $cred -Hostname $hostname

 

#Get all URIs of Nodes in the System
$UriBasket = Get-SwisData $target "SELECT Uri FROM Orion.Nodes"

 

I searched high and low and I can not find what this error means (An error occurred when verifying security for the message.).

 

FYI, I am able to log on with the same account via a web browser, so I know the account has access.

 

Any help would be greatly appreciated.

 

Not sure I put this in the right group either.

 

Thanks, Jon

Receiving 403 Forbidden When Using REST API In C#

$
0
0

Receiving 403 Forbidden When Using REST API In C#

 

I was referred to the following C# example of using REST APIs Sample code: OrionSDK/Program.cs at master · solarwinds/OrionSDK · GitHub

 

This looked very promising and I have attempted to implement it for my process. However, all requests are failing with a 403 Forbidden error.

 

I have verified if I used invalid credentials I get a 401 unauthorized error so it appears to be authenticating my request, but I can't get results for a simple query operation.

 

I am basically using the code from the example but I am only calling the query action with the following simple query string and no arguments:

conststring query = @"SELECT nodeid, caption FROM Orion.Nodes";

 

I have output the JSON string created before it is passed to the request and it looks like this:

{"parameters":null,"query":"SELECT nodeid, caption FROM Orion.Nodes"}

 

Is there something wrong with the JSON or my query request?

Query nodes based on custom property

$
0
0

Hello,

 

Is there any way to query the Orion nodes with all the custom properties?

 

Thanks.

CluM09

Mapping F5 Big-IP to Host or IP with SWQL

$
0
0

Hi,

 

I hope this is an easy question. 

 

I am trying to map out our current IP, to see if they are part of the F5 load balancer. 

 

I came to the orion.f5.LTM.VirtualIPAddress table, however there does not seem to have any unique identifier to join the orion.nodes table.  Also, that the IPAddress table has %(port numbers?) appended to it. 

 

Am I looking in the correct place?

 

Please help, much appreciated.  Thank you!

 

How do I use PowerShell To Add Graphs To A View?

$
0
0

I am looking for a way to add resources to a view, via PowerShell.

Currently, using SWQL Studio to invoke "AddResourceToView", I can supply the 3 arguments (viewId, config, & moveColliding), and successfully add a new resource to a view.

I want to put that workflow into a PowerShell script, allowing me to easily change the view and SWQL query results.


This is what I have, so far:

Here is the standard connection part of the script:

# Connections, and stuff

$ErrorActionPreference = 'Stop'

# Set up the hostname, username, and password for the source system
$hostname = "meow";
#$password1 = New-Object System.Security.SecureString  #"" | ConvertTo-SecureString -asPlainText -Force
$username = "arf"
$password = "moo" | ConvertTo-SecureString -asPlainText -Force

# Load the SwisSnapin if not already loaded
if (!(Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {
    Add-PSSnapin "SwisSnapin"
}

# Connect to the source system
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
$swis = Connect-Swis -Credential $credential -Hostname $hostname

function IsEmpty($str) {
    $str -eq $null -or $str -eq '' -or $str.GetType() -eq [DBNull]
}

 

 

Here is the part where I set the arguments for the verb jammy-thing:

# Verb argument 1

# The "AddResourceToView" verb requires 3 arguments to successfully add a new resource to a view. (I think it only requires the first 2)
# The "AddResourceToView" verb requires "viewId", "config", & "moveColliding", in this order.
# Verb argument 1
# This is the viewID of the page/view on which to add the new graph(s).
$viewId="211"
#$viewId=[int32]211

 

 

# Verb argument 2 (I am not actually using the "\" character before "<resource...", but this post seems to keep removing the rest of the lines for some reason.

# The "config" argument should be a string containing xml like this:
# https://thwack.solarwinds.com/message/344536#344536
# This is the SWQL query that will return the "config" portion, having filled in the Node/Interface data in the appropriate places.
#$configs= Get-SwisData $swis "SELECT '\<resource name="Custom Object Resource" file="/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx" column="1" position="1" title="" subtitle=""><properties><property name="AutoHide" value="0"/><property name="Calculate95thPercentile" value="0"/><property name="CalculateSum" value="0"/><property name="CalculateTrendLine" value="0"/><property name="ChartDateSpan" value="2"/><property name="ChartInitialZoom" value="24h"/><property name="ChartName" value="AvgBps-Line"/><property name="ChartSubtitle" value="${ZoomRange}"/><property name="ChartTitle" value="${Caption}"/><property name="CustomObjectMode" value="0"/><property name="EmbeddedObjectResource" value="/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;"/><property name="EntityName" value="Orion.NPM.Interfaces"/><property name="FilterEntities" value="False"/><property name="HideThreshold" value="0"/><property name="Initialized" value="True"/><property name="NetObjectID" value="I:'+TOSTRING(n.Interfaces.InterfaceID)+'"/><property name="NetObjectPrefix" value="I"/><property name="NumberOfSeriesToShow" value="0"/><property name="ObjectUri" value="'+n.Interfaces.Uri+'"/><property name="SampleSize" value="5"/><property name="SelectedEntities" value="'+TOSTRING(n.Interfaces.InterfaceID)+'"/><property name="ShowTitle" value="1"/><property name="SubTitle" value=""/><property name="Title" value=""/></properties></resource>' AS [AvgBps-Line_configCol-1] FROM Orion.Nodes AS n WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'"
$configs= [String[]](Get-SwisData $swis "SELECT '\<resource name=""Custom Object Resource"" file=""/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx"" column=""1"" position=""1"" title="""" subtitle=""""><properties><property name=""AutoHide"" value=""0""/><property name=""Calculate95thPercentile"" value=""0""/><property name=""CalculateSum"" value=""0""/><property name=""CalculateTrendLine"" value=""0""/><property name=""ChartDateSpan"" value=""2""/><property name=""ChartInitialZoom"" value=""24h""/><property name=""ChartName"" value=""AvgBps-Line""/><property name=""ChartSubtitle"" value=""${ZoomRange}""/><property name=""ChartTitle"" value=""${Caption}""/><property name=""CustomObjectMode"" value=""0""/><property name=""EmbeddedObjectResource"" value=""/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;""/><property name=""EntityName"" value=""Orion.NPM.Interfaces""/><property name=""FilterEntities"" value=""False""/><property name=""HideThreshold"" value=""0""/><property name=""Initialized"" value=""True""/><property name=""NetObjectID"" value=""I:'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""NetObjectPrefix"" value=""I""/><property name=""NumberOfSeriesToShow"" value=""0""/><property name=""ObjectUri"" value=""'+n.Interfaces.Uri+'""/><property name=""SampleSize"" value=""5""/><property name=""SelectedEntities"" value=""'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""ShowTitle"" value=""1""/><property name=""SubTitle"" value=""""/><property name=""Title"" value=""""/></properties></resource>' AS [meow] FROM Orion.Nodes AS n WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'")
#$configs= [String](Get-SwisData $swis "SELECT '\<resource name=""Custom Object Resource"" file=""/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx"" column=""1"" position=""1"" title="""" subtitle=""""><properties><property name=""AutoHide"" value=""0""/><property name=""Calculate95thPercentile"" value=""0""/><property name=""CalculateSum"" value=""0""/><property name=""CalculateTrendLine"" value=""0""/><property name=""ChartDateSpan"" value=""2""/><property name=""ChartInitialZoom"" value=""24h""/><property name=""ChartName"" value=""AvgBps-Line""/><property name=""ChartSubtitle"" value=""${ZoomRange}""/><property name=""ChartTitle"" value=""${Caption}""/><property name=""CustomObjectMode"" value=""0""/><property name=""EmbeddedObjectResource"" value=""/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;""/><property name=""EntityName"" value=""Orion.NPM.Interfaces""/><property name=""FilterEntities"" value=""False""/><property name=""HideThreshold"" value=""0""/><property name=""Initialized"" value=""True""/><property name=""NetObjectID"" value=""I:'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""NetObjectPrefix"" value=""I""/><property name=""NumberOfSeriesToShow"" value=""0""/><property name=""ObjectUri"" value=""'+n.Interfaces.Uri+'""/><property name=""SampleSize"" value=""5""/><property name=""SelectedEntities"" value=""'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""ShowTitle"" value=""1""/><property name=""SubTitle"" value=""""/><property name=""Title"" value=""""/></properties></resource>' AS [meow] FROM Orion.Nodes AS n WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'")
#$configs= Get-SwisData $swis "SELECT '\<resource name=""Custom Object Resource"" file=""/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx"" column=""1"" position=""1"" title="""" subtitle=""""><properties><property name=""AutoHide"" value=""0""/><property name=""Calculate95thPercentile"" value=""0""/><property name=""CalculateSum"" value=""0""/><property name=""CalculateTrendLine"" value=""0""/><property name=""ChartDateSpan"" value=""2""/><property name=""ChartInitialZoom"" value=""24h""/><property name=""ChartName"" value=""AvgBps-Line""/><property name=""ChartSubtitle"" value=""${ZoomRange}""/><property name=""ChartTitle"" value=""${Caption}""/><property name=""CustomObjectMode"" value=""0""/><property name=""EmbeddedObjectResource"" value=""/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;""/><property name=""EntityName"" value=""Orion.NPM.Interfaces""/><property name=""FilterEntities"" value=""False""/><property name=""HideThreshold"" value=""0""/><property name=""Initialized"" value=""True""/><property name=""NetObjectID"" value=""I:'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""NetObjectPrefix"" value=""I""/><property name=""NumberOfSeriesToShow"" value=""0""/><property name=""ObjectUri"" value=""'+n.Interfaces.Uri+'""/><property name=""SampleSize"" value=""5""/><property name=""SelectedEntities"" value=""'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""ShowTitle"" value=""1""/><property name=""SubTitle"" value=""""/><property name=""Title"" value=""""/></properties></resource>' AS [meow] FROM Orion.Nodes AS n WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'"

 

 

# Verb argument 3

# This is the 3rd, and final, verb argument required to create the new resource on the page.
# Setting this to "True" will bump down any resource already configured to the same column/row as the resource being added.
#$moveColliding="True"
#$moveColliding=[boolean]"True"

 

# And here is the part where I think it is supposed to loop through each result, from the SWQL query in argument 2, and add a new resource to the view from argument 1

foreach ($config in $configs) {    # config.meow = the data from the SWQL query?
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @("$viewId", @{config=$config.meow})
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @("$viewId", @{config="$config.meow"})    Invoke-SwisVerb $swis Orion.Views AddResourceToView @("$viewId", $config.meow)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @($viewId, $configs)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @($viewId, $configs, $moveColliding)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @{viewId=$viewId, $configs, $moveColliding}
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@{viewId=$viewId, $configs, $moveColliding})
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@($viewId, $configs, $moveColliding))
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@($viewId, $config.meow, $moveColliding))
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @( ,@($viewId, $config.meow, $moveColliding))
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @( ,@($viewId, @{config = $config.meow}, $moveColliding))
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @($viewId, @{config = $config.meow}, $moveColliding)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @("$viewId", @{config = $config.meow}, "$moveColliding")
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@($viewId), @{config = $config.meow}, $moveColliding)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@(211), @{config = $config.meow}, $moveColliding)
}

 

 

 

As you can see by the commented lines above, I have tried several different ways. I have searched through numerous different Thwack posts, related to SDK, API, PowerShell, Invoke-SwisVerb, etc., and have tried to apply advice from those various posts, with no success.

 

Most of the different ways I have failed ended with actual error messages in PowerShell ISE, as seen below:

Invoke-SwisVerb : Verb Orion.Views.AddResourceToView cannot unpackage parameter 1 of type System.String
Invoke-SwisVerb : Object of type 'System.String[]' cannot be converted to type 'System.String'.
Invoke-SwisVerb : There are multiple root elements. Line 1, position 1544.
Get-SwisData : Cannot bind parameter 'Parameters'. Cannot convert the "SELECT '
Invoke-SwisVerb : Type 'System.Management.Automation.PSObject' with data contract name 'PSObject:http://schemas.datacontract.org/2004/07/System.Management.Automation' is not expected. 
Invoke-SwisVerb : There was an error generating the XML document.

 

 

While I have virtually no idea what I am doing here (that's why they make labs, right?), I was able to get, what I think, is a valid error message, as in the script ran, but each attempt to add the new resource failed. (As opposed to the script itself failing)

PS C:\Users\Administrator> Z:\powershell script examples\DEV_Add_Graph_To_View.ps1


xmlns                                                                          #text
-----                                                                          -----
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false

 

 

 

 

This is the SWQL query I use to build the config file, which works fine when I copy/paste the results from the SWQL query into the invoke page within SWQL Studio, but not PowerShell.

SELECT
'<resource name="Custom Object Resource" file="/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx" column="1" position="1" title="" subtitle=""><properties><property name="AutoHide" value="0"/><property name="Calculate95thPercentile" value="0"/><property name="CalculateSum" value="0"/><property name="CalculateTrendLine" value="0"/><property name="ChartDateSpan" value="2"/><property name="ChartInitialZoom" value="24h"/><property name="ChartName" value="AvgBps-Line"/><property name="ChartSubtitle" value="${ZoomRange}"/><property name="ChartTitle" value="${Caption}"/><property name="CustomObjectMode" value="0"/><property name="EmbeddedObjectResource" value="/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;"/><property name="EntityName" value="Orion.NPM.Interfaces"/><property name="FilterEntities" value="False"/><property name="HideThreshold" value="0"/><property name="Initialized" value="True"/><property name="NetObjectID" value="I:'+TOSTRING(n.Interfaces.InterfaceID)+'"/><property name="NetObjectPrefix" value="I"/><property name="NumberOfSeriesToShow" value="0"/><property name="ObjectUri" value="'+n.Interfaces.Uri+'"/><property name="SampleSize" value="5"/><property name="SelectedEntities" value="'+TOSTRING(n.Interfaces.InterfaceID)+'"/><property name="ShowTitle" value="1"/><property name="SubTitle" value=""/><property name="Title" value=""/></properties></resource>' AS [meow]
FROM Orion.Nodes AS n
WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'

 

 

 

I am hoping someone can point me in the direction closest to the answer I seek.

 

 

Thank you,

 

-Will


Can any one supply a REST example of how to define a Node in Solarwinds

$
0
0

I am developing an integration agent for SolarWindws and would like to use the REST API to add nodes to SolarWindws and change the system name

How do I use PowerShell To Add Graphs To A View?

$
0
0

I am looking for a way to add resources to a view, via PowerShell.

Currently, using SWQL Studio to invoke "AddResourceToView", I can supply the 3 arguments (viewId, config, & moveColliding), and successfully add a new resource to a view.

I want to put that workflow into a PowerShell script, allowing me to easily change the view and SWQL query results.


This is what I have, so far:

Here is the standard connection part of the script:

# Connections, and stuff

$ErrorActionPreference = 'Stop'

# Set up the hostname, username, and password for the source system
$hostname = "meow";
#$password1 = New-Object System.Security.SecureString  #"" | ConvertTo-SecureString -asPlainText -Force
$username = "arf"
$password = "moo" | ConvertTo-SecureString -asPlainText -Force

# Load the SwisSnapin if not already loaded
if (!(Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {
    Add-PSSnapin "SwisSnapin"
}

# Connect to the source system
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
$swis = Connect-Swis -Credential $credential -Hostname $hostname

function IsEmpty($str) {
    $str -eq $null -or $str -eq '' -or $str.GetType() -eq [DBNull]
}

 

 

Here is the part where I set the arguments for the verb jammy-thing:

# Verb argument 1

# The "AddResourceToView" verb requires 3 arguments to successfully add a new resource to a view. (I think it only requires the first 2)
# The "AddResourceToView" verb requires "viewId", "config", & "moveColliding", in this order.
# Verb argument 1
# This is the viewID of the page/view on which to add the new graph(s).
$viewId="211"
#$viewId=[int32]211

 

 

# Verb argument 2 (I am not actually using the "\" character before "<resource...", but this post seems to keep removing the rest of the lines for some reason.

# The "config" argument should be a string containing xml like this:
# https://thwack.solarwinds.com/message/344536#344536
# This is the SWQL query that will return the "config" portion, having filled in the Node/Interface data in the appropriate places.
#$configs= Get-SwisData $swis "SELECT '\<resource name="Custom Object Resource" file="/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx" column="1" position="1" title="" subtitle=""><properties><property name="AutoHide" value="0"/><property name="Calculate95thPercentile" value="0"/><property name="CalculateSum" value="0"/><property name="CalculateTrendLine" value="0"/><property name="ChartDateSpan" value="2"/><property name="ChartInitialZoom" value="24h"/><property name="ChartName" value="AvgBps-Line"/><property name="ChartSubtitle" value="${ZoomRange}"/><property name="ChartTitle" value="${Caption}"/><property name="CustomObjectMode" value="0"/><property name="EmbeddedObjectResource" value="/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;"/><property name="EntityName" value="Orion.NPM.Interfaces"/><property name="FilterEntities" value="False"/><property name="HideThreshold" value="0"/><property name="Initialized" value="True"/><property name="NetObjectID" value="I:'+TOSTRING(n.Interfaces.InterfaceID)+'"/><property name="NetObjectPrefix" value="I"/><property name="NumberOfSeriesToShow" value="0"/><property name="ObjectUri" value="'+n.Interfaces.Uri+'"/><property name="SampleSize" value="5"/><property name="SelectedEntities" value="'+TOSTRING(n.Interfaces.InterfaceID)+'"/><property name="ShowTitle" value="1"/><property name="SubTitle" value=""/><property name="Title" value=""/></properties></resource>' AS [AvgBps-Line_configCol-1] FROM Orion.Nodes AS n WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'"
$configs= [String[]](Get-SwisData $swis "SELECT '\<resource name=""Custom Object Resource"" file=""/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx"" column=""1"" position=""1"" title="""" subtitle=""""><properties><property name=""AutoHide"" value=""0""/><property name=""Calculate95thPercentile"" value=""0""/><property name=""CalculateSum"" value=""0""/><property name=""CalculateTrendLine"" value=""0""/><property name=""ChartDateSpan"" value=""2""/><property name=""ChartInitialZoom"" value=""24h""/><property name=""ChartName"" value=""AvgBps-Line""/><property name=""ChartSubtitle"" value=""${ZoomRange}""/><property name=""ChartTitle"" value=""${Caption}""/><property name=""CustomObjectMode"" value=""0""/><property name=""EmbeddedObjectResource"" value=""/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;""/><property name=""EntityName"" value=""Orion.NPM.Interfaces""/><property name=""FilterEntities"" value=""False""/><property name=""HideThreshold"" value=""0""/><property name=""Initialized"" value=""True""/><property name=""NetObjectID"" value=""I:'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""NetObjectPrefix"" value=""I""/><property name=""NumberOfSeriesToShow"" value=""0""/><property name=""ObjectUri"" value=""'+n.Interfaces.Uri+'""/><property name=""SampleSize"" value=""5""/><property name=""SelectedEntities"" value=""'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""ShowTitle"" value=""1""/><property name=""SubTitle"" value=""""/><property name=""Title"" value=""""/></properties></resource>' AS [meow] FROM Orion.Nodes AS n WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'")
#$configs= [String](Get-SwisData $swis "SELECT '\<resource name=""Custom Object Resource"" file=""/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx"" column=""1"" position=""1"" title="""" subtitle=""""><properties><property name=""AutoHide"" value=""0""/><property name=""Calculate95thPercentile"" value=""0""/><property name=""CalculateSum"" value=""0""/><property name=""CalculateTrendLine"" value=""0""/><property name=""ChartDateSpan"" value=""2""/><property name=""ChartInitialZoom"" value=""24h""/><property name=""ChartName"" value=""AvgBps-Line""/><property name=""ChartSubtitle"" value=""${ZoomRange}""/><property name=""ChartTitle"" value=""${Caption}""/><property name=""CustomObjectMode"" value=""0""/><property name=""EmbeddedObjectResource"" value=""/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;""/><property name=""EntityName"" value=""Orion.NPM.Interfaces""/><property name=""FilterEntities"" value=""False""/><property name=""HideThreshold"" value=""0""/><property name=""Initialized"" value=""True""/><property name=""NetObjectID"" value=""I:'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""NetObjectPrefix"" value=""I""/><property name=""NumberOfSeriesToShow"" value=""0""/><property name=""ObjectUri"" value=""'+n.Interfaces.Uri+'""/><property name=""SampleSize"" value=""5""/><property name=""SelectedEntities"" value=""'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""ShowTitle"" value=""1""/><property name=""SubTitle"" value=""""/><property name=""Title"" value=""""/></properties></resource>' AS [meow] FROM Orion.Nodes AS n WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'")
#$configs= Get-SwisData $swis "SELECT '\<resource name=""Custom Object Resource"" file=""/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx"" column=""1"" position=""1"" title="""" subtitle=""""><properties><property name=""AutoHide"" value=""0""/><property name=""Calculate95thPercentile"" value=""0""/><property name=""CalculateSum"" value=""0""/><property name=""CalculateTrendLine"" value=""0""/><property name=""ChartDateSpan"" value=""2""/><property name=""ChartInitialZoom"" value=""24h""/><property name=""ChartName"" value=""AvgBps-Line""/><property name=""ChartSubtitle"" value=""${ZoomRange}""/><property name=""ChartTitle"" value=""${Caption}""/><property name=""CustomObjectMode"" value=""0""/><property name=""EmbeddedObjectResource"" value=""/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;""/><property name=""EntityName"" value=""Orion.NPM.Interfaces""/><property name=""FilterEntities"" value=""False""/><property name=""HideThreshold"" value=""0""/><property name=""Initialized"" value=""True""/><property name=""NetObjectID"" value=""I:'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""NetObjectPrefix"" value=""I""/><property name=""NumberOfSeriesToShow"" value=""0""/><property name=""ObjectUri"" value=""'+n.Interfaces.Uri+'""/><property name=""SampleSize"" value=""5""/><property name=""SelectedEntities"" value=""'+TOSTRING(n.Interfaces.InterfaceID)+'""/><property name=""ShowTitle"" value=""1""/><property name=""SubTitle"" value=""""/><property name=""Title"" value=""""/></properties></resource>' AS [meow] FROM Orion.Nodes AS n WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'"

 

 

# Verb argument 3

# This is the 3rd, and final, verb argument required to create the new resource on the page.
# Setting this to "True" will bump down any resource already configured to the same column/row as the resource being added.
#$moveColliding="True"
#$moveColliding=[boolean]"True"

 

# And here is the part where I think it is supposed to loop through each result, from the SWQL query in argument 2, and add a new resource to the view from argument 1

foreach ($config in $configs) {    # config.meow = the data from the SWQL query?
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @("$viewId", @{config=$config.meow})
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @("$viewId", @{config="$config.meow"})    Invoke-SwisVerb $swis Orion.Views AddResourceToView @("$viewId", $config.meow)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @($viewId, $configs)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @($viewId, $configs, $moveColliding)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @{viewId=$viewId, $configs, $moveColliding}
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@{viewId=$viewId, $configs, $moveColliding})
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@($viewId, $configs, $moveColliding))
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@($viewId, $config.meow, $moveColliding))
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @( ,@($viewId, $config.meow, $moveColliding))
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @( ,@($viewId, @{config = $config.meow}, $moveColliding))
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @($viewId, @{config = $config.meow}, $moveColliding)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @("$viewId", @{config = $config.meow}, "$moveColliding")
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@($viewId), @{config = $config.meow}, $moveColliding)
#    Invoke-SwisVerb $swis Orion.Views AddResourceToView @(@(211), @{config = $config.meow}, $moveColliding)
}

 

 

 

As you can see by the commented lines above, I have tried several different ways. I have searched through numerous different Thwack posts, related to SDK, API, PowerShell, Invoke-SwisVerb, etc., and have tried to apply advice from those various posts, with no success.

 

Most of the different ways I have failed ended with actual error messages in PowerShell ISE, as seen below:

Invoke-SwisVerb : Verb Orion.Views.AddResourceToView cannot unpackage parameter 1 of type System.String
Invoke-SwisVerb : Object of type 'System.String[]' cannot be converted to type 'System.String'.
Invoke-SwisVerb : There are multiple root elements. Line 1, position 1544.
Get-SwisData : Cannot bind parameter 'Parameters'. Cannot convert the "SELECT '
Invoke-SwisVerb : Type 'System.Management.Automation.PSObject' with data contract name 'PSObject:http://schemas.datacontract.org/2004/07/System.Management.Automation' is not expected. 
Invoke-SwisVerb : There was an error generating the XML document.

 

 

While I have virtually no idea what I am doing here (that's why they make labs, right?), I was able to get, what I think, is a valid error message, as in the script ran, but each attempt to add the new resource failed. (As opposed to the script itself failing)

PS C:\Users\Administrator> Z:\powershell script examples\DEV_Add_Graph_To_View.ps1


xmlns                                                                          #text
-----                                                                          -----
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract false

 

 

 

 

This is the SWQL query I use to build the config file, which works fine when I copy/paste the results from the SWQL query into the invoke page within SWQL Studio, but not PowerShell.

SELECT
'<resource name="Custom Object Resource" file="/Orion/NetPerfMon/Resources/Misc/CustomObjectResource.ascx" column="1" position="1" title="" subtitle=""><properties><property name="AutoHide" value="0"/><property name="Calculate95thPercentile" value="0"/><property name="CalculateSum" value="0"/><property name="CalculateTrendLine" value="0"/><property name="ChartDateSpan" value="2"/><property name="ChartInitialZoom" value="24h"/><property name="ChartName" value="AvgBps-Line"/><property name="ChartSubtitle" value="${ZoomRange}"/><property name="ChartTitle" value="${Caption}"/><property name="CustomObjectMode" value="0"/><property name="EmbeddedObjectResource" value="/Orion/Interfaces/Resources/InterfaceCharts/InterfaceChart.ascx;ChartName=AvgBps-Line;ChartInitialZoom=48h;Calculate95thPercentile=0;CalculateSum=0;CalculateTrendLine=0;ChartDateSpan=1;SampleSize=5;ChartTitle=${Caption};ChartSubTitle=${ZoomRange};ShowTitle=1;"/><property name="EntityName" value="Orion.NPM.Interfaces"/><property name="FilterEntities" value="False"/><property name="HideThreshold" value="0"/><property name="Initialized" value="True"/><property name="NetObjectID" value="I:'+TOSTRING(n.Interfaces.InterfaceID)+'"/><property name="NetObjectPrefix" value="I"/><property name="NumberOfSeriesToShow" value="0"/><property name="ObjectUri" value="'+n.Interfaces.Uri+'"/><property name="SampleSize" value="5"/><property name="SelectedEntities" value="'+TOSTRING(n.Interfaces.InterfaceID)+'"/><property name="ShowTitle" value="1"/><property name="SubTitle" value=""/><property name="Title" value=""/></properties></resource>' AS [meow]
FROM Orion.Nodes AS n
WHERE n.Interfaces.CustomProperties.Comments='InternetUplink'

 

 

 

I am hoping someone can point me in the direction closest to the answer I seek.

 

 

Thank you,

 

-Will

Add node with snmpv3 credentials

$
0
0

Hi

 

We have just moved one of our rigs to NPM 12 and it looks like it has broken some of our SDK automation while we can add devices that use SNMPv2 those with SNMPv3 (which as it turns out is all our new devices) fail to add giving the below error.

 

New-SwisObject : Invalid column name 'SNMPV3PrivKeyIsPwd'.

Invalid column name 'SNMPV3AuthKey'.

Invalid column name 'SNMPV3PrivMethod'.

Invalid column name 'SNMPV3AuthMethod'.

Invalid column name 'SNMPV3PrivKey'.

Invalid column name 'SNMPv3Username'.

Invalid column name 'SNMPV3Context'.

Invalid column name 'SNMPV3AuthKeyIsPwd'.

 

I suspect something has moved around in the schema and this now needs creating in a different way but there is nothing obvious around how to make the necessary changes.

 

We have SDK v2.1.13 in place

 

JonG

Error while Upgrading a node from icmp monitoring to snmp

$
0
0

Query:

Set-SwisObject $swis -Uri 'swis://hostname/Orion/Orion.Nodes/NodeID=2' -Properties @{ ObjectSubType='SNMP';SNMPVersion='2';AgentPort='162';Allow64BitCounters='True';Community='public';RWCommunity='public' }

 

 

Error:

Set-SwisObject : Invalid column name 'SNMPV3Username'.

Invalid column name 'SNMPV3PrivMethod'.

Invalid column name 'SNMPV3PrivKey'.

Invalid column name 'SNMPV3AuthMethod'.

Invalid column name 'SNMPV3AuthKey'.

At E:\Pulkit\EditSNMP.ps1:8 char:1

+ Set-SwisObject $swis -Uri 'swis://hostname/Orion/Orion.Nodes/No ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [Set-SwisObject], FaultException`1

    + FullyQualifiedErrorId : SwisError,SwisPowerShell.SetSwisObject

 

Note:-  For other properties this query is working fine, even if a set "AgentPort" alone it works fine but when i set the property "ObjectSubType" or "Community" this error occurs.

tdanner

Please help!

403 with rest api call

$
0
0

I;ve seen a few other people with this issue, and some where resolved, but nowhere is a solution to be found.

 

The code:

 

$VLANNAAM = "Somevlan"

$cred = get-credential

$invoked = Invoke-RestMethod -Uri ("https://"+$Hostname+":17778/SolarWinds/InformationService/v3/Json/Query?query=SELECT GroupId,VLAN_Naam FROM IPAM.GroupNodeAttr WHERE (VLAN_Naam='$VLANNAAM')") -method Get -credential $cred

 

For the credentials I've used a windows account, local account, database user.

Nothing works, Always the 403 error.

 

2015-08-27 07_33_58-Pool 06 - ICT Services Windows 8 Werkplek.png

Viewing all 3719 articles
Browse latest View live