4 Replies Latest reply on Dec 22, 2016 4:31 PM by KMSigma

    Invoke-SwisVerb: Access to Orion.Nodes.Unmanage verb denied.

    eli.warren

      I am working on a script that I can fee a list of servers to and unmanage the servers.

       

      I can get all the moving parts to work, but when it comes to the actual invoke-swisverb the script tanks.

       

      Here is what I have:

       

      $FilePath = Read-Host -Prompt "Input file path to list"

      $silenceTime = Read-Host -Prompt "Enter time to silence Servers"

       

       

      ForEach ($nodename in (Get-Content -Path $filePath)){

           Write-Host $nodename

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

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

           $now =[DateTime]::UtcNow

           $later =$now.AddMinutes($silenceTime)

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

           }

        • Re: Invoke-SwisVerb: Access to Orion.Nodes.Unmanage verb denied.
          eli.warren

          Powershell error message

           

          Invoke-SwisVerb : Access to Orion.Nodes.Unmanage verb denied.

          At C:\temp\warren\unmanage-solarwinds.ps1:33 char:2

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

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

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

              + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

          • Re: Invoke-SwisVerb: Access to Orion.Nodes.Unmanage verb denied.
            KMSigma
            <#
            Two things
            1) You don't need to build up a Swis connection for each call - you can create one at the beginning and then close it when you are done all of your work.
            2) The first parameter in your Invoke-SwisVerb argument list is bad.  The preface for nodes is "N:", so your first variable in the argument list should be "N:$nodeid"
            Since you can unmanage (nearly) anything in Orion, you need to specify the type of element.  Review the SwisVerbs section on this page.
            Here's my sample script:
            #>
            if ( -not ( Get-PSSnapin -Name "SwisSnapin" -ErrorAction SilentlyContinue ) )
            {    
                Add-PSSnapin SwisSnapin -ErrorAction SilentlyContinue
            }
            $NodeNames = "NOCWDS01v", "NOCWDS02v", "NOCWHD01v"
            $silenceTime = [int]60
            $SwisUsername = "admin"
            $SwisPassword = "This is not the password you are looking for" 
            $SwisCreds    = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $SwisUsername, ( $SwisPassword | ConvertTo-SecureString -AsPlainText -Force )
            $OrionServer  = "10.196.3.50"
            
            $Swis = Connect-Swis -Host $OrionServer -Credential $SwisCreds
            
            ForEach ( $NodeName in $NodeNames )
            {
                Write-Verbose -Message "Querying SWIS on $OrionServer for Nodes with Caption [$( $NodeName )]"
                $NodeId = Get-SwisData -SwisConnection $Swis -Query "SELECT NodeID FROM Orion.Nodes WHERE Caption = '$NodeName'"
                if ( $NodeId )
                {
            
                    $NodeDescriptor = "N:$NodeId" # <-- This is your error - you need to use "N:" to indicate a "node" to be unmanaged
                    $UnmanageBegin = [DateTime]::UtcNow
                    $UnmanageEnd  = $UnmanageBegin.AddMinutes($silenceTime)
                    Write-Verbose -Message "Setting Unmanage for NodeID $NodeID from $( $UnmanageBegin.ToShortDateString() ) @ $( $UnmanageBegin.ToShortTimeString() ) until $( $UnmanageEnd.ToShortDateString() ) @ $( $UnmanageEnd.ToShortTimeString() )"
                    $Results = Invoke-SwisVerb -SwisConnection $Swis -EntityName Orion.Nodes -Verb Unmanage -Arguments @($NodeDescriptor, $UnmanageBegin, $UnmanageEnd, "false")
                }
            }
            $Swis.Close() # now I'm done with the work in Swis and can close and remove the variable.
            Remove-Variable -Name Swis -ErrorAction SilentlyContinue
            
            1 of 1 people found this helpful