Quantcast
Channel: THWACK: Message List
Viewing all articles
Browse latest Browse all 22513

Re: Determine how Solarwinds could be manipulated for automation

$
0
0

I don't know about deploys, but I have setup a Powershell script for Windows server patching.   It makes use of the SolarWinds Orion SDK, which is free to download.   I use the below Powershell functions to Unmanage and Manage servers.

 

#Unmanages remote server in Orion
Function Unmanage-Servers {
[cmdletbinding()]
Param ($computername)

#Load Orion SWIS Snapin
Add-PSSnapin SWISSnapin

#Initialize variables
$username = '********' #Replace with an Orion SQL username with manage rights
$password = '********' #Replace with the password of the Orion SQL username
$hostname = 'orion.domain.com' #Replace with the URL of the Orion server
$hours = 24

#Connect to Orion Server
$swis = Connect-Swis -Username $username -Password $password -Hostname $hostname

#Change computer name to IP if local computer
If ($computername -eq $env:computername){
  $computername = (Get-WmiObject -class win32_NetworkAdapterConfiguration -Filter 'ipenabled = "true"').ipaddress[0]
}

#Get Node Info
$nodeid = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes WHERE SysName like '$computername' or IP_Address like '$computername'"

#Unmanage Node
$now = [DateTime]::UtcNow
$later = $now.AddHours($hours)
Invoke-SwisVerb $swis Orion.Nodes Unmanage @("N:$nodeid",$now,$later,"false")
}

 

#Manages remote server in Orion
Function Manage-Servers {
[cmdletbinding()]
Param ($computername)

#Load Orion SWIS Snapin
Add-PSSnapin SWISSnapin

#Initialize variables
$username = '********' #Replace with an Orion SQL username with manage rights
$password = '********' #Replace with the password of the Orion SQL username
$hostname = 'orion.domain.com' #Replace with the URL of the Orion server

#Connect to Orion Server
$swis = Connect-Swis -Username $username -Password $password -Hostname $hostname

#Change computer name to IP if local computer
If ($computername -eq $env:computername){
  $computername = (Get-WmiObject -class win32_NetworkAdapterConfiguration -Filter 'ipenabled = "true"').ipaddress[0]
}

#Get Node Info
$nodeid = Get-SwisData $swis "SELECT NodeID FROM Orion.Nodes WHERE SysName like '$computername' or IP_Address like '$computername'"

#Remanage Node
Invoke-SwisVerb $swis Orion.Nodes Remanage @("N:$nodeid")
}


Viewing all articles
Browse latest Browse all 22513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>