Version 1

    Working with nickzourdos today on an issue he found where he needed to enable hardware health polling on ~80 devices that were pre-existing in NPM.

    It should be noted that all devices are the same make/model. This is important.

     

    Step 1: Research

    Hardware Health · solarwinds/OrionSDK Wiki · GitHub

    It seems we need the NetObjectID and the PollingMethod for this

     

    Step 2: A little more research

    Query SWIS via the SWQL Studio to get a sample of the PollingMethod used on an existing device

    You can grab the SWQL Studio Here: Releases · solarwinds/OrionSDK · GitHub

     

    Query:

    SELECT PollingMethod, ParentObjectType, ParentObjectID FROM Orion.HardwareHealth.HardwareInfoBase WHERE ParentObjectType = 'N' AND ParentObjectID =<NodeID of Sample Node>

     

    Step 3: Execute the below script in PowerShell, supplying the Hostname, Login to SolarWinds, PollingMethod, and Search Criteria for your nodes (Nick is a solid admin and has a very nice standard naming convention!)

     

    #region Top of Script
    
    #requires -version 2
    <#
    .SYNOPSIS 
        Enables Hardware Health Pollers for Nick's Nodes 
    
    .DESCRIPTION 
        https://github.com/solarwinds/OrionSDK/wiki/Hardware-Health
    
    .NOTES
        Version:        1.0
        Author:         Zack Mutchler
        Creation Date:  July 12, 2018
        Purpose/Change: Initial Script development.  
    #>
    
    #endregion
    
    #####-----------------------------------------------------------------------------------------#####
    
    #region Functions
    
    # Create a function to connect to the SolarWinds Information Service (SWIS)
    Function Set-SwisConnection {
        
        Param(
            [ Parameter( Mandatory = $true, HelpMessage = "What SolarWinds server are you connecting to (Hostname or IP)?" ) ] [ string ] $SolarWindsServer,
            [ Parameter( Mandatory = $true, HelpMessage = "Do you want to use the credentials from PowerShell (Trusted), or a new login (Explicit)?" ) ] [ ValidateSet( 'Trusted', 'Explicit' ) ] [ string ] $ConnectionType
        )
    
        # Import the SolarWinds PowerShell Module
        Import-Module SwisPowerShell
    
        # Connect to SWIS
        IF ( $ConnectionType -eq 'Trusted'  ) {
    
            $swis = Connect-Swis -Trusted -Hostname $SolarWindsServer
        
        }
    
        ELSE {
        
            $creds = Get-Credential -Message "Please provide a Domain or Local Login for SolarWinds"
    
            $swis = Connect-Swis -Credential $creds -Hostname $SolarWindsServer
    
        }
    
    RETURN $swis
    
    }
    
    #endregion Functions
    
    #####-----------------------------------------------------------------------------------------#####
    
    #region Variables
    
    # Connect to SWIS
    $hostname = Read-Host -Prompt "Hostname or IP Address of your SolarWinds server"
    $swis = Set-SwisConnection -SolarWindsServer $hostname -ConnectionType Explicit
    
    # Build the wildcard search for the Node Names
    $captions = Read-Host -Prompt "Partial Name for the Hosts you want to target (Wildcard will be added in the script, do not use it here)"
    $queryParam = "%" + $captions + "%"
    
    # Supply the Polling Method to be applied to all target nodes
    $pollingMethod = Read-Host "What is the polling method (integer) to be used?"
    
    # Query all of the target nodes to build list of NodeIDs and Captions
    $nodeQuery = "SELECT NodeID, Caption FROM Orion.Nodes WHERE Caption LIKE @caption"
    $nodes = Get-SwisData -SwisConnection $swis -Query $nodeQuery -Parameters @{ caption = $queryParam }
    
    #endregion Variables
    
    #####-----------------------------------------------------------------------------------------#####
    
    #region Execution
    
    # Iterate through the Nodes and enable hardware health
    Foreach( $n in $nodes ) {
    
        # Setup the ID and Name variables
        $netObjectID = "N:" + $n.NodeID 
        $nodeName = $n.Caption 
    
        # Set the hardware pollers for the nodes
        Try{
        
            $results = Invoke-SwisVerb -SwisConnection $swis -EntityName Orion.HardwareHealth.HardwareInfoBase -Verb EnableHardwareHealth -Arguments @( $netObjectID, $pollingMethod )
    
            Write-Host "Hardware Health Enabled for: $( $nodeName )" -ForegroundColor Green
    
        }
    
        Catch{
    
            $ErrorMessage = $_.Exception.Message
            Write-Host "The error message was $( $ErrorMessage )" -ForegroundColor Yellow
    
        }
    
    }
    
    #endregion Execution

     

     

    Note: If you get an error that you're missing the Module, run this in PowerShell:

    Install-Module -Name SwisPowerShell

     

    ref: PowerShell Gallery | SwisPowerShell 2.3.0.108