This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Script to Unmanage all hosts in a CSV file

Simple script to unmanage a group of nodes in NPM using the Powershell SWIS api and reading the list of hosts from a simple CSV file.

Some simple customization will be required for the CSV filename and columns however it should be simple enough to do.

Also the username/password and hostname of the Solarwinds system will be required as will the Solarwinds SWIS API installed.

UnmanageNodes.ps1
  • Thank you for posting this. It appears this script requires the Node ID in the CSV file to function. Is there anyway for the script to lookup the NodeID from just the hostname or IP?

  • A very slick script, up there hopefully someone can answer my question.

    The script below works like a charm,

    Is there anyway to add a fixed DateTime for $now and $later ?

    In other words we have to unmanage the hosts on Fridays at 7pm till Saturday, 1am, unmanaged for 6 hours

    Thanks for your help

    Add-PSSnapin SwisSnapin

    $Hostname = @()

    $NodeID = @()

    Import-Csv C:\Scripts\Solarwinds\Hosts.csv | ForEach-Object { $Hostname += $_."Hostname"; $NodeID += $_.NodeID }

    $swis = Connect-Swis -host "XXXX" -UserName "xxxx" -Password "xxxx"

    For ($i=0; $i -lt $NodeID.length; $i++) {

        $now=[DateTime]::UtcNow

        #$now="Friday, May 11, 2018 7:00:00 PM"

        $later=$now.AddMinutes(5)

        #$later="Saturday, May 12, 2018 1:00:00 AM"

        $NodeIdStr = "N:" + $NodeID[$i]

        $NodeIdStr

        $WhatTime = Invoke-SwisVerb $swis Orion.Nodes Unmanage @($NodeIdStr,$now,$later,"false")

        $WhatTime

        $Hostname[$i]

        $NodeID[$i]

    }