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

Creating a last 24hr reboot noc view

$
0
0

Hi,

 

When I run this query, I get a different time as to the actual lastboot time, but when I checked the message center for last reboot event time, it is correct.  Any ideas, or does anyone have any recommended query to create a Node Last Reboot in 24 hours?


Thank you!

 

 

 

SELECT e.Nodes.Caption, EventTime as RebootTime

FROM Orion.Events e

where eventtype = 14

and HOURDIFF(eventtime, GETUTCDATE()) < 24

order by eventtime desc


how to input 'y' or 'yes' with powershell script to NCM

$
0
0

Hello, Team

is anybody who can give me an idea how to input the 'yes' or 'y' command when waiting for the user input.

want to automate the Nexus 3048 ios upgrade process with powershell script with NCM.

 

Also, powershell script can apply for multiple devices at the same time for example upgrade 100 devices at the same time for 1 powershell script.

 

for example

Images will be upgraded according to following table:

Module             Image         Running-Version             New-Version  Upg-Required

------  ----------------  ----------------------  ----------------------  ------------

     1            system             6.0(2)U1(2)             6.0(2)U3(1)           yes

     1         kickstart             6.0(2)U1(2)             6.0(2)U3(1)           yes

     1              bios      v1.2.0(08/25/2011)      v1.2.0(08/25/2011)            no

     1         power-seq                    v4.4                    v4.4            no

 

 

Switch will be reloaded for disruptive upgrade.

Do you want to continue with the installation (y/n)?  [n] y   <--- here, how to input 'y' command with powershell script ??

 

Install is in progress, please wait.

Performing runtime checks.

[####################] 100% -- SUCCESS

Setting boot variables.

[####################] 100% -- SUCCESS

Performing configuration copy.

[####################] 100% -- SUCCESS

Finishing the upgrade, switch will reboot in 10 seconds.

as20a.w40216b.x460.krccw#

Delete Network Discovery through API

$
0
0

Is there a method to delete a completed network discovery via the API?  I've successfully automated the addition of nodes through the network discovery but would like to do cleanup afterwards so that those discoveries don't pile up. 

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.

Alexa programming example from SolarWinds Lab Episode #51

$
0
0

I had a bunch of questions from today's SolarWidns Lab episode, "BREAKING UP WITH BAD HABITS: Monitoring, Security, and Orion -- DON'TS".  I wrapped up with a 10 minute SolarWinds SDK programming class, integrating the Orion Platform with an Amazon Alexa custom skill.  It's Nodejs, AWS Lambda, Alexa and of course SolarWinds SWIS, SQL and SDK.

 

Below I've added the JavaScript I put together to query Orion from from AWS Lambda.  Check out the lab video for the tutorial and let me know if this was helpful.

 

Lambda Nodejs file that backends the skill we create in the episode:

 

'use strict';


const https = require('https');


const swisPath = '/SolarWinds/InformationService/v3/Json/Query?query=';


const weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];


function zeroPad(number) {
    return (number < 10) ? '0' + number : number;
}


function fixDate(date) {
    var local = new Date(date.setHours(date.getHours() - 6));    var hours = local.getHours();    if (hours === 0)        hours = 12;    else if (hours > 12)        hours = hours - 12;    var formatted = weekdays[local.getDay()] + ', <say-as interpret-as="date">????'        + zeroPad(local.getMonth() + 1) + zeroPad(local.getDate()) + '</say-as> at <say-as interpret-as="time">'        + hours + ':' + zeroPad(local.getMinutes())        + ((local.getHours() < 12) ? ' A' : ' P') + 'M</say-as>';    console.log('formattted: ', formatted)       return formatted;
}


function swisGetRESTrequest(swisQuery) {
    return new Promise(function(resolve, reject) {        https.get({            host: process.env.SWIS_HOST,            port: 17778,            rejectUnauthorized: false,            path: swisPath + swisQuery.replace(/ /g, '+'), // escape the spaces            headers: {                'Authorization': 'Basic ' + new Buffer(process.env.SWIS_USER + ':' + process.env.SWIS_PASS).toString('base64'),                'Accept': '*/*'            }        }, function(response) {            // Continuously update stream with data            var body = '';            response.on('data', function(d) {                body += d;            });            response.on('end', function() {                // Data reception is done, do whatever with it!                //console.log('httpsOnEnd body:' + body);                               var jsonReply = JSON.parse(body);                               // test for results element ==                if (!jsonReply.hasOwnProperty('results')) {                    console.log('"results" not found in: ' + jsonReply);                    reject(jsonReply);                }                resolve(jsonReply);            });        }).on('error', function(err) {            reject(err);        });    });
}


function getOrionAccounts(callback) {
    var query = 'SELECT AccountID, Enabled, AllowNodeManagement, AllowMapManagement, AllowAdmin, CanClearEvents, AllowReportManagement, AllowAlertManagement,'        + ' AllowCustomize, AllowUnmanage, AllowDisableAction, AllowDisableAlert, AllowDisableAllActions, AlertSound, MenuName, HomePageViewID,'        + ' DefaultNetObjectID, DisableSessionTimeout, ReportFolder, AlertCategory, Expires, LastLogin, LimitationID1, LimitationID2, LimitationID3,'        + ' AccountSID, AccountType, AllowViewCopCheck FROM Orion.Accounts'        + ' ORDER BY LastLogin DESC'        + ' WITH ROWS 1 TO 10 WITH TOTALROWS';       swisGetRESTrequest(query).then(function(response) {        console.log('getSWISdata response:', response);               var accountTotal = response.totalRows;        var textOut = '<p>There are ' + accountTotal + ' accounts on the Orion server.</p>';        for(var i = 0; i < response.results.length; i++) {            var result = response.results[i];            //console.log('result: ', result);            var date = new Date(result.LastLogin);            textOut = textOut + '<p>' + result.AccountID + ', is '                + ((result.Enabled == 'Y') ? 'enabled' : 'disabled')                + ((date.getFullYear() > 1900) ? '. Last log in was ' + fixDate(date) : ', and has never logged in') + '.</p>';        }        if (accountTotal > 0) {            console.log('textOut: ' + textOut);            sendAlexaReply(textOut, callback, true);        }        else {            sendAlexaReply('Hmm. SWIS is talking, but I can\'t understand what it\'s saying.', callback, true);        }           }, function(error) {        console.error('getSWISdata failure', error);        sendAlexaReply('Oops, The SWISS call failed.', callback, true);    });
}


function sendAlexaReply(text, callback, endSesson) {
    var reply = {        "version": "1.0",        "response": {            "outputSpeech": {                "type": text.indexOf('</')  == -1 ? "PlainText" : "SSML",            },            "shouldEndSession": endSesson        }    };       if (text.indexOf('</')  == -1)        reply.response.outputSpeech.text = text;    else        reply.response.outputSpeech.ssml = "<speak>" + text + "</speak>";    callback(null, reply);
}


exports.handler = (event, context, callback) => {    //const alexa = Alexa.handler(event, context);       console.log('event: ' + JSON.stringify(event));    console.log('context: ' + JSON.stringify(context));       switch (event.request.type) {        case 'IntentRequest':            switch(event.request.intent.name) {                case 'GetOrionAccounts':                    getOrionAccounts(callback);                    break;                case 'SayOk':                    sendAlexaReply('No problem.', callback, true);                    break;                case 'GetStatus':                    sendAlexaReply('Patrick.  You have 126 active alerts.', callback, true);                    break;              case 'AMAZON.HelpIntent':                    sendAlexaReply('You can ask me to help with status, geek tasks, or, you can say exit... '                        + 'What can I help you with?', callback, false);                    break;                case 'AMAZON.CancelIntent':                case 'AMAZON.StopIntent':                case 'SessionEndedRequest':                    sendAlexaReply('OK.', callback, true);                    break;                default:                    console.log('action: unknown');            }            break;               case 'LaunchRequest':            sendAlexaReply('You can ask me to help with status, geek tasks, or, you can say exit... '                + 'What can I help you with?', callback, false);            break;                   default:            sendAlexaReply('Sorry, I don\'t know what to do with request type "'                + event.request.type + '".', callback, true);    }
};

Active Alerts - Creating a duplicated view

$
0
0

Hi,

 

I am in need of creating an exact duplicate "Active Alerts View", but also need to filter the alerts to specific type of alerts.  This is because the View Limitation can not filter by Specific Alerts, and I can't use the Accounts alerts limitation category because everyone logs into the same group.

 

Short story, I found a SWQL query here for it, but I can't seem to find the "Active Time".. any ideas where this is located, or how I can get Active Time to display as in Active Alerts View?

 

SELECT 

  o.AlertConfigurations.Name AS [ALERT NAME] 

  ,'/Orion/NetPerfMon/ActiveAlertDetails.aspx?NetObject=AAT:' + ToString(o.AlertObjectID) AS [_LinkFor_ALERT NAME]

  ,o.AlertActive.TriggeredMessage AS [ALERT MESSAGE] 

  ,o.EntityCaption AS [ALERT OBJECT] 

  ,o.EntityDetailsURL AS [_LinkFor_ALERT OBJECT]

,ToLocal(o.AlertActive.TriggeredDateTime) AS [ALERT TRIGGER TIME]  

,o.RelatedNodeCaption AS [RELATED NODE] 

,o.RelatedNodeDetailsURL AS [_LinkFor_RELATED NODE] 

FROM Orion.AlertObjects o 

WHERE o.AlertActive.TriggeredMessage <> '' and o.AlertConfigurations.Name = 'Critical'

 

A bonus, anyone knows how to add the icons or color as well?

PowerShell or Python ?

$
0
0

Ive taken a few python classes at school a while back and while I enjoyed it I never used it too much in the real world. From doing research and reading various posts I seem to have this feeling that knowing powershell vs python would put me in a much better position to excel as a SolarWinds admin.  Curious on Tdanners and others thoughts. 

Custom Properties - How to audit for changes

$
0
0

Hi,

 

I have a question, and I can't seem to find it.  Is there a way to be able to audit a custom property field, to be able to run a report to see who changed the property and when?


The reason is, we have setup a Mute_Node property, and would like to audit to see who muted it and when.

 

Thanks much!


Orion SDK with PowerShell - manage/unmanage multiple nodes

$
0
0

I've been able to script unmanaging and managing nodes in powershell. However, for 400+ nodes, this ends up taking quite a while. Via script, it takes about 7 minutes to unmanage the nodes and over 10 minutes to remanage them. Doing this from the website takes about 25 seconds and no more than a minute, respectively. My guess is that the website somehow group updates the database instead of doing it one at a time. Anyone else seen this or have any idea how to do more than one node at a time? Below is sample code for how I am unmanaging a single node:

 

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

 

Thanks for any advice you have!

Creating a last 24hr reboot noc view

$
0
0

Hi,

 

When I run this query, I get a different time as to the actual lastboot time, but when I checked the message center for last reboot event time, it is correct.  Any ideas, or does anyone have any recommended query to create a Node Last Reboot in 24 hours?


Thank you!

 

 

 

SELECT e.Nodes.Caption, EventTime as RebootTime

FROM Orion.Events e

where eventtype = 14

and HOURDIFF(eventtime, GETUTCDATE()) < 24

order by eventtime desc

Executing NCM script with PowerShell

$
0
0

I'm just starting to get my head around the powershell/sdk goodness and have a few queries based on the example here: https://github.com/solarwinds/OrionSDK/blob/master/Samples/PowerShell/NCM.ExecuteScript.ps1.

 

Credentials

 

If I configure the logon as username password :

 

$hostname = "MyOrionServerName"
$username = "MyUSerName"
$plainpass = "MyPlainTextPassword"
$swis = Connect-Swis -v2 -host $hostname -username $username -password $plainpass

 

The script completes and produces the results as expected.

 

However, I'd rather not have plain text username/password combination in my script, so changing to certificate based credentials, and running the script in ISE as administrator:

 

$hostname = "MyOrionServerName"
$username = "MyUSerName"
$swis = Connect-Swis -Certificate

 

I get the error:

 

Invoke-SwisVerb : System.Data.SqlClient.SqlException --> String or binary data would be truncated.
The statement has been terminated.
At C:\scripts\NCM.ps1:45 char:1
+ Invoke-SwisVerb $swis Cirrus.ConfigArchive Execute @($nodeIdList, $script, $user ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1
    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

at this:

 

 Invoke-SwisVerb $swis Cirrus.ConfigArchive Execute @($nodeIdList, $script, $username) | Out-Null

 

 

and the job fails to complete.

 

Any input here appreciated.

 

Output

 

I have added the (working) code to a template we have for sending emails.  When the job completes, Write-Host$outputpresents to the debug window nicely formatted text.

 

 

If however I send $output to the email, the text just becomes a single continuous string:

 

I've tried ConvertTo-HTML:

 

$($output | ConvertTo-Html -fragment | out-string)

 

which produces the completely non-helpful:

Now, in all honesty, I'm nowhere near a PowerShell expert, so I'd be gratful for any pointers on what I am (clearly) doing wrong that is stopping the text being a nicely formatted table

 

Thanks

Stuart

Integrating SolarWinds with Netcool

$
0
0

Hi All,

 

Is it possible to integrate SolarWinds with IBM Tivoli Netcool OMNIbus? If so, then what would be the requirements from our end (SolarWinds per se) for this integration?

 

Thank you very  much.

Deleting Interfaces

$
0
0

I am creating a basic script that will ultimately automatically remove loopback, mgmt., null interfaces and others once a week.  The script below does return Uri's as intended however when I add the remove object statement it throws an error I do not understand

 

$ErrorActionPreference = 'Stop'

 

#Add the snapin

 

Add-PSSnapin SwisSnapin

 

#create a connection to solarwinds

 

$hostname = '10.X.X.X'
$username = 'admin'
$password = 'XXXXX'

 

#swis = Connect-Swis -Hostanme $hostname -Trusted

 

$swis = Connect-Swis -Hostname $hostname -Username $username -Password $password

 

#Query Data

 

$query = Get-SwisData $swis "Select uri FROM Orion.NPM.interfaces WHERE InterfaceName = 'lo'"

 

# This returns the following Uri's

swis://XXXX.my.domain.net/Orion/Orion.Nodes/NodeID=123/Interfaces/InterfaceID=321

swis://XXXX.my.domain.net/Orion/Orion.Nodes/NodeID=456/Interfaces/InterfaceID=654

swis://XXXX.my.domain.net/Orion/Orion.Nodes/NodeID=789/Interfaces/InterfaceID=987

 

# When adding the final remove object line...

 

$query | ForEach-Object { Remove-SwisObject $swis $query }

 

I get the error below

 

ForEach-Object : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter

'Uri'. Specified method is not supported.

At C:\Users\nsd000.QACMA\Documents\PowerShell Scripts\Do not Modify\Delete Loopbacks MGMT and Null

Interfaces.ps1:22 char:10

+ $query | ForEach-Object { Remove-SwisObject $swis $query }

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

    + CategoryInfo          : InvalidArgument: (:) [ForEach-Object], ParameterBindingException

    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.ForEachObjectComma

   nd

 

This format works well when I use the same logic on the script below.  The only difference I can see is that the script above is pulling from Orion.NPM.Interfaces and the one below is Orion.Volumes

 

$ErrorActionPreference = 'Stop'

#Add the snapin
Add-PSSnapin SwisSnapin

#create a connection to solarwinds

$hostname = '10.xXX'

$username = 'admin'

$password = 'XXXXX'

#swis = Connect-Swis -Hostanme $hostname -Trusted
$swis = Connect-Swis -Hostname $hostname -Username $username -Password $password

#Query Data

$query = Get-SwisData $swis "Select uri FROM Orion.volumes WHERE VolumeDescription = 'Cached Memory' AND VolumePercentUsed ='100'"

# Remove Objects 

$query | ForEach-Object { Remove-SwisObject $swis $query }

Remove Non Cisco Devices from UDT

$
0
0

We have an issue where users will add servers into UDT.  Our methodology is to only allow access switches in UDT.  I have created the script below to identify all devices where the vendor is not Cisco.   It brings back the expected Uri's however when I add the Remove-SwisObject statement it errors out. 

 

$ErrorActionPreference = 'Stop'

 

#Add the snapin
Add-PSSnapin SwisSnapin

 

#create a connection to solarwinds

$hostname = 'X'
$username = 'X'
$password = 'X'

 

#swis = Connect-Swis -Hostanme $hostname -Trusted
$swis = Connect-Swis -Hostname $hostname -Username $username -Password $password

 

#Query Data

$query = Get-SwisData $swis "SELECT u.uri FROM Orion.UDT.Port u JOIN Orion.Nodes n ON n.nodeid = u.nodeid WHERE n.vendor <> 'cisco'"

 

# The line above does finds the Uri's below.  Which happen to be the devices I want GONE!

swis://XXX.net/Orion/Orion.Nodes/NodeID=160/Ports/PortID=1
swis://XXX.net/Orion/Orion.Nodes/NodeID=160/Ports/PortID=2
swis://XXX.net/Orion/Orion.Nodes/NodeID=160/Ports/PortID=3
swis://XXX.net/Orion/Orion.Nodes/NodeID=160/Ports/PortID=4
swis://XXX.net/Orion/Orion.Nodes/NodeID=162/Ports/PortID=5

 

# Remove Objects

$query | Remove-SwisObject $swis

 

# Error when adding $query | Remove-SwisObject $swis

 

Remove-SwisObject : Operation not supported on Orion.UDT.Port
At C:\Users\nsd000.QACMA\Documents\PowerShell Scripts\Do not Modify\Remove Non Cisco Devices From UDT.ps1:22 char:10
+ $query | Remove-SwisObject $swis
+          ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Remove-SwisObject], FaultException`1
    + FullyQualifiedErrorId : SwisError,SwisPowerShell.RemoveSwisObject

PowerOrion - Works in IDE and No Where Else

$
0
0

I have a script to add a Node and then Custom Properties.  I wrote the script in PowerShell IDE and when I run it in IDE it works.  When I save it and run it from a PowerShell window it fails.

 

I am not running in x86, I am running as Adminstrator.

 

I am getting the following errors-

Get-SwisObject : Cannot bind argument to parameter 'SwisConnection' because it is null.

At C:\windows\system32\windowspowershell\v1.0\Modules\PowerOrion\PowerOrion.psm1:226 char:45

+                 $nodeProps = Get-SwisObject $swis -Uri $newNode

+                                             ~~~~~

    + CategoryInfo          : InvalidData: (:) [Get-SwisObject], ParameterBindingValidationException

    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,SwisPowerShell.GetSwisObject

 

 

Cannot index into a null array.

At C:\windows\system32\windowspowershell\v1.0\Modules\PowerOrion\PowerOrion.psm1:231 char:21

+                     $nodeSettings = @{

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

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : NullArray

 

My Script:

##Decalre Variables

Import-Module PowerOrion

 

 

#SWIS Connection

$Hostname = "corpmonap28rm39.safeautonet.net"

 

 

#SNMP

$SNMPVersion = "SNMPv2"

$CommunityString = "rad"

 

 

#Server Information

 

$ServerName = 'MyServerName'

#Get DNS Name From IP

$ServerIP = (resolve-dnsname -Type A $ServerName).IPAddress

 

 

 

 

#SolarWinds Custom Properties

$PatchGroupProd3 = 'PROD3'

$EmailTo = "MyEmail"

$EmailCC = ""

$Environment = "Production"

$Description = "TEST PowerShell"

$Site = "HQ"

 

 

$SWNodeProperties = @{

 

 

Email_To = $EmailTo;

Email_CC = $EmailCC;

PatchGroup = $PatchGroupProd3;

Environment = $Environment;

SA_Description = $Description;

Site = $Site;

 

 

}

 

 

 

 

Write-Host $ServerName

Write-Host $ServerIP

 

 

$swis = Connect-Swis -Hostname $Hostname

New-OrionNode -SwisConnection $swis -ObjectSubType $SNMPVersion -Community $CommunityString  -IPAddress $ServerIP -engineid "1"

#New-OrionNode -SwisConnection $swis

$URI = (get-orionnode -IPAddress $ServerIP -SwisConnection $swis).URi

Write-Host $URI

Set-SwisObject -Uri $URI -Properties @{ Caption = $ServerName  } -SwisConnection $swis

Set-SwisObject $swis $URI/CustomProperties -Properties $SWNodeProperties


how to input 'y' or 'yes' with powershell script to NCM

$
0
0

Hello, Team

is anybody who can give me an idea how to input the 'yes' or 'y' command when waiting for the user input.

want to automate the Nexus 3048 ios upgrade process with powershell script with NCM.

 

Also, powershell script can apply for multiple devices at the same time for example upgrade 100 devices at the same time for 1 powershell script.

 

for example

Images will be upgraded according to following table:

Module             Image         Running-Version             New-Version  Upg-Required

------  ----------------  ----------------------  ----------------------  ------------

     1            system             6.0(2)U1(2)             6.0(2)U3(1)           yes

     1         kickstart             6.0(2)U1(2)             6.0(2)U3(1)           yes

     1              bios      v1.2.0(08/25/2011)      v1.2.0(08/25/2011)            no

     1         power-seq                    v4.4                    v4.4            no

 

 

Switch will be reloaded for disruptive upgrade.

Do you want to continue with the installation (y/n)?  [n] y   <--- here, how to input 'y' command with powershell script ??

 

Install is in progress, please wait.

Performing runtime checks.

[####################] 100% -- SUCCESS

Setting boot variables.

[####################] 100% -- SUCCESS

Performing configuration copy.

[####################] 100% -- SUCCESS

Finishing the upgrade, switch will reboot in 10 seconds.

as20a.w40216b.x460.krccw#

Assign Custom Properties

$
0
0

I would like to assign custom properties to the nodes found via query.  As an example I would like to assign all devices in the 10.22.0.0/16 range the custom property Environment "QA".  The custom properties are already in place.  The script returns the Uri's I am after.  I do not know how to assign the new custom properties however.  

 

$ErrorActionPreference = 'Stop'

 

#Add the snapin
Add-PSSnapin SwisSnapin

 

#create a connection to solarwinds

$hostname = 'xx'
$username = 'xx'
$password = 'XX'

 

#swis = Connect-Swis -Hostanme $hostname -Trusted

 

$swis = Connect-Swis -Hostname $hostname -Username $username -Password $password

 

$query = Get-SwisData $swis "SELECT uri FROM Orion.Nodes WHERE ip_address LIKE '10.22.%'"

 

$query

 

swis://XX.net/Orion/Orion.Nodes/NodeID=151
swis://XX.net/Orion/Orion.Nodes/NodeID=116
swis://XX.net/Orion/Orion.Nodes/NodeID=146

SWQL works in studio but not in Website

$
0
0

After migrating to NPM 12.1 I've decided to update my SQL queries to SWQL queries since row limit started to bother me and searchable textbox seems to be legit.

 

My swql query looks like:

 

select
case when ccs.Availability=1 then 'Up' else 'Down' end as STATUS,
'/NetPerfmon/images/Small-' + case when ccs.Availability=1 then 'Up' else 'Down' end + '.gif' as _IconFor_STATUS,
n.Caption, c.Name,
ccs.TimeStamp,
ccs.LastTimeUp,
ccs.ErrorMessage
from
Orion.Nodes n, Orion.APM.Component c, Orion.APM.Application a, Orion.APM.CurrentComponentStatus ccs
where
n.NodeID=a.NodeID and
ccs.ApplicationID=a.ID and
ccs.ComponentID=c.ComponentID and
a.Name like 'Windows %' and
c.Name <> 'Task Scheduler' and
(c.Status=1 or c.Status=2) and
a.Unmanaged=0

 

It works perfectly on swql studio but not on custom query on website. Any comments?

 

Thanks.

Disabling Hardware Health Sensors

$
0
0

tdanner et. al;

 

Can anyone identify what the "DisableSensors" verb is looking for in Orion.HardwareHealth.HardwareItem ?

 

Trying the ID is coming back with an error in PowerShell:

 

Script:

 

# Clear PowerShell and add the SwisSnapin
Clear-Host

if (-not (Get-PSSnapin | Where-Object { $_.Name -eq 'SwisSnapin' })) {
    Add-PSSnapin 'SwisSnapin'
}

# Connect to SWIS using AD pass-through
$hostname = 'SolarWindsPoller'
$swis = Connect-Swis -Hostname $hostname -Trusted

# Query SWIS to get an array of Sensor IDs to disable
$query = "SELECT ID, FullyQualifiedName FROM Orion.HardwareHealth.HardwareItem WHERE Name LIKE 'System Memory'"
$results = Get-SwisData $swis $query

#  Loop through the array to disable the sensors
Foreach($sensor in $results){    Invoke-SwisVerb $swis Orion.HardwareHealth.HardwareItem DisableSensors $($sensor[0].ID)    Write-Host "Disabling Hardware Sensor On: $($sensor[0].FullyQualifiedName)"
}

 

 

This is an example of what is being passed (adding a Write-Host to the front of the Invoke)

 

Invoke-SwisVerb SolarWinds.InformationService.Contract2.InfoServiceProxy Orion.HardwareHealth.HardwareItem DisableSensors 136

Disabling Hardware Sensor On: System Memory on hostname.domain.local

 

 

And this is the error:

 

Invoke-SwisVerb : Verb Orion.HardwareHealth.HardwareItem.DisableSensors cannot unpackage parameter 0 of type System.Collections.Generic.IEnumerable`1[SolarWinds.HardwareHealth.Common.Models.HardwareHealth.HardwareHealthItemKey]

At line:36 char:2

+     Invoke-SwisVerb $swis Orion.HardwareHealth.HardwareItem DisableSe ...

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

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

    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

 

 

Any and all help is appreciated!

Remove-SwisObject : mismatched input 'False' expecting 'Identifier' in Select clause - Is this a bug?

$
0
0

Trying to script delete of nodes. Works in the QA environment and fails in PRD.

 

Get the URI here:

if (-not (Get-PSSnapin | where {$_.Name -eq "SwisSnapin"}))
{    Add-PSSnapin "SwisSnapin";
}
$swis = Connect-Swis -host SolarWindsOrionServer -UserName 'REDACTED' -Password 'ALSO_REDACTED'
$a = Get-SwisData $swis 'SELECT Uri FROM Orion.nodes where caption = @host' @{host = 'Test123456'}
Remove-SwisObject -SwisConnection $swis -Uri $a

 

This returns the following:

Remove-SwisObject : mismatched input 'False' expecting 'Identifier' in Select clause

At line:1 char:1

+ Remove-SwisObject -SwisConnection $swis -Uri ([string]$a)

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

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

    + FullyQualifiedErrorId : SwisError,SwisPowerShell.RemoveSwisObject

 

$a.getType() returns that it is a string

 

I have tried several formats including using the literal URI string:

Remove-SwisObject -SwisConnection $swis -Uri 'swis://FCDARSVRMSQ23P.fcb.com/Orion/Orion.Nodes/n:9608'

 

What am I missing?

We're running the following:

PRD on Win 2008 R2

Orion Platform 2015.1.3, NCM 7.4.1, SRM 6.2.1, WPM 2.2.1, DPA 10.0.1, NPM 11.5.3, IVIM 2.1.1, QoE 2.0, SAM 6.2.3, NTA 4.1.2

 

QA on Win 2012 R2

Orion Platform 2015.1.3, NCM 7.4.1, SRM 6.2.1, WPM 2.2.0, DPA 10.0.1, NPM 11.5.3, IVIM 2.1.1, SAM 6.2.3, NTA 4.1.2

 

Attached is the tail end of C:\ProgramData\Solarwinds\InformationService\v3.0\Orion.InformationService.log that has the failure. The last attempt is as close to 2017-03-21 15:18:00 as I could manage.

Viewing all 3719 articles
Browse latest View live