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.

Invoke-SwisVerb to Enable Application Dependency Polling for a Node?

I've been sifting through the available verbs for this, but I'm not sure if there is one. Basically I'm looking for a way to automate checking the "Application Dependency Polling Enabled" checkbox for a node. These are all nodes that have the agent already installed.

Parents
  • Hi chadsikorra

    You can enable/disable Application Dependency Polling by invoking verb:

    Orion.ADM.NodeInventory.Enable and Orion.ADM.NodeInventory.Disable

    You need to pass array of ids of nodes. In order to pass an array of integers, the following xml must be constructed and passed as an argument:

    <ArrayOfint xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">

       <int>1</int>

    </ArrayOfint>

    Hope this helps

    pawelk

  • Note that the XML is only needed from PowerShell. From HTTPS, you can use the Json syntax, which is a little more concise:

    [ 1 ]

  • I'm having issues with this.  Can you spot what I'm doing wrong?

    I tried it via the PowerShell module (with both 2.5.0.214 & 3.0.0.336), and found a method of constructing the arguments that gets accepted, but doesn't actually effect any change:

    2.5.0.214:

    SwisPowerShell 2.5.0.214

    3.0.0.336

    3.0.0.336

    The version of Orion is 20.20.2.6 HF1

    Here's the code I tried:

    <#
    #    These different methods didn't work
    $NodeIds = 2727
    
    $NodeIds = @(2727)
    
    $NodeIds = "<ArrayOfint xmlns:i=`"http://www.w3.org/2001/XMLSchema-instance`" xmlns=`"http://schemas.microsoft.com/2003/10/Serialization/Arrays`"><int>2727</int></ArrayOfint>"
    
    $NodeIds = @"
    {
      "nodeIds": [
        2727
      ]
    }
    "@
    #>
    
    #   This method is accepted, but doesn't make a change in the database
    $NodeIds = @{"nodeIds" = @(2727)}
    
    Invoke-SwisVerb -SwisConnection $swis -EntityName Orion.ADM.NodeInventory -Verb Disable -Arguments @($NodeIds)

    It works if I invoke it through SWQL Studio:

    So I tried using Postman to do pure HTTP/REST, but also didn't have success there:

    Am I doing it wrong?

Reply
  • I'm having issues with this.  Can you spot what I'm doing wrong?

    I tried it via the PowerShell module (with both 2.5.0.214 & 3.0.0.336), and found a method of constructing the arguments that gets accepted, but doesn't actually effect any change:

    2.5.0.214:

    SwisPowerShell 2.5.0.214

    3.0.0.336

    3.0.0.336

    The version of Orion is 20.20.2.6 HF1

    Here's the code I tried:

    <#
    #    These different methods didn't work
    $NodeIds = 2727
    
    $NodeIds = @(2727)
    
    $NodeIds = "<ArrayOfint xmlns:i=`"http://www.w3.org/2001/XMLSchema-instance`" xmlns=`"http://schemas.microsoft.com/2003/10/Serialization/Arrays`"><int>2727</int></ArrayOfint>"
    
    $NodeIds = @"
    {
      "nodeIds": [
        2727
      ]
    }
    "@
    #>
    
    #   This method is accepted, but doesn't make a change in the database
    $NodeIds = @{"nodeIds" = @(2727)}
    
    Invoke-SwisVerb -SwisConnection $swis -EntityName Orion.ADM.NodeInventory -Verb Disable -Arguments @($NodeIds)

    It works if I invoke it through SWQL Studio:

    So I tried using Postman to do pure HTTP/REST, but also didn't have success there:

    Am I doing it wrong?

Children
  • Your PowerShell is a little off.  For the moment - completely ignore the nodeIds XML you are seeing in SWQL Studio. 

    If you look on the right-side of the invoke area, it says System.Int32[] which means an array of integers.  This means that the verb is expecting an integer array as the parameter.

    Your setup is correct - it does need to be a hashtable for the argument.

    $NodeIdsToChange = 1, 7, 11, 1052 # Build the integer array of Node IDs
    
    $NodeIdsToChange | Get-Member | Select-Object -Property TypeName -Unique # Shows the Types
    
    $NodeIdsToChange -is [Array] # Shows if it's an array
    
    $Arguments = @{ nodeIds = $NodeIdsToChange } # Build the arguments
    
    $Arguments | Get-Member | Select-Object -Property TypeName -Unique # Shows the Types
    
    $Arguments -is [Array] # shows that this is NOT an array, even though it contains an array
    

    When you are actually calling the verb, you are sending @( $thing ) as the parameter value.  The @() tells that I want to convert this $thing to an array... but we don't want that.  We want everything packaged up as a single object.

    Sorry for the long post, but Hashtables, Arrays, and PowerShell Custom Objects can get confusing.  I'm hoping this helps some other people as well.

    TL;DR: Remove the @( and ) from around your $NodeIds in the Invoke-SwisVerb line and you should be ok.

  • Thank you for the explanation, I actually thought the @() in -Arguments @($variable) was part of the SwisPowerShell syntax, so this really helped.

    Unfortunately, it doesn't work Disappointed

    I tried with:

    $Arguments = @{ nodeIds = @(2727, 2728)}  #First tried with only one node ID, added a second in case that was the problem
    Invoke-SwisVerb -SwisConnection $swis -EntityName Orion.ADM.NodeInventory -Verb Disable -Arguments $Arguments

    But the nodes still remain with Application Dependency enabled

    Could this be similar to the issue here? Unable to execute EnablePollingForNodes or DisablePollingForNodes - Orion SDK - The Orion Platform - THWACK (solarwinds.com)

  • Perhaps.  I'm assuming when you tweaked your PowerShell script, you didn't get any errors this time?

    I just tested and saw a similar thing.  Best bet is to log an issue on GitHub.  Drop a link to it here and I'll do my own test.  Be sure to outline a few details so that the developers can understand what's what.

  • For those that did not figure out the syntax for PowerShell, here is what works for me.

    I am finding a list of nodes that need the ADM setting disabled and disabling the setting one by one as I loop through the results.

    The weird syntax is how you have to pass the single value as an array in the command.

    @( ,@( $_.NodeID ) )

    ## Search for NON-agent nodes in the ADM.NodeInventory table
    $nodeInfo = Get-SwisData $swis "SELECT NI.NodeID, NI.Node.Caption, NI.Node.IPAddress, NI.Node.ObjectSubType
            FROM Orion.ADM.NodeInventory NI
            WHERE (NI.Node.ObjectSubType != 'Agent')"
    
    ## Check to verify results are found.
    if (!$nodeInfo) {
    	Write-Host "`n`nNo results found."
    }else {
    	$nodeInfo | foreach {
    		Write-Host "`n`nProcessing..."
    		Write-Host "The nodeID is:" $_.NodeID
    		Write-Host "The nodeName is:" $_.Caption
    		Write-Host "The IPAddress is:" $_.IPAddress
            Write-Host "The node type is:" $_.ObjectSubType
    		
            ## Call the Invoke-SwisVerb command to disable the ADM setting at the node level.  Passing an array with a single value.
            Invoke-SwisVerb -SwisConnection $swis -EntityName Orion.ADM.NodeInventory -Verb Disable -Arguments @( ,@( $_.NodeID ) )
    
        }
    }