cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 7

How to use WMI credentials stored in Orion with Powershell?

Hello everyone,

I'm currently working on a Powershell script that sends a "lodctr" command to several servers in my network (in this case, Windows 2003 Servers). The problem here is that to use an Invoke-Command inside Powershell, I need to input the credentials for each server individually and I'm working with a lot of servers. How can I use the WMI credentials that are already stored inside Solarwinds? The script I was working on is the following:

Add-PSSnapin SwisSnapin

$now = Get-Date

$later =$now.AddYears(99)

$creds = Get-Credential

$swis = Connect-Swis -Credential $creds -Hostname 10.161.236.25

$a = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes where Nodes.Description = @nodeDescription" @{nodeDescription = "Windows 2003 Server"}

Write-Host $a

foreach ($i in $a)

{

    # Unmanage

    Invoke-SwisVerb $swis Orion.APM.Application Unmanage @("N: $i", $now, $later, "false")

    # Lodctr /R

    Invoke-Command -ComputerName ${Node.Caption} -Credential ${CREDENTIAL} -ScriptBlock{lodctr /R:""}

    # Remanage

    Invoke-SwisVerb $swis Orion.APM.Application Remanage @("N: $i", $now, $later, "false")

}

Thanks!

Tags (3)
0 Kudos
1 Reply
Level 14

Inside of the template you need to edit the component.  If you want to use the credential applied to the node you would set the following:

2014-12-04_08h55_52.png

Inside of your script you are already calling the credential correctly using the -credential ${CREDENTIAL} string.

Let me know if this works!