I need to enable Asset Inventory on a number of servers. I am using the Node.Inventory.Enable.ps1 from OrionSDK/Samples/PowerShell/Node.Inventory.Enable.ps1 at master · solarwinds/OrionSDK · GitHub.
Import-Module SwisPowerShell
#Connect to SWIS
Add-PSSnapin swissnapin
$username = ""
$SecurePassword = ConvertTo-SecureString -AsPlainText -Force -String ""
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $Securepassword
$hostname = ""
$swis = Connect-Swis -host $hostname -cred $Cred
$query = "
SELECT
N.NodeID
FROM
Orion.Nodes N
WHERE
N.CustomProperties.Purpose = 'GC'
"
$nodeids = Get-SwisData -SwisConnection $swis -Query $query
# details about the reason for the arguments format can be found here:
# https://github.com/solarwinds/OrionSDK/wiki/Alerts#verb-resumealerts
Invoke-SwisVerb -SwisConnection $swis -Entity 'Orion.ADM.NodeInventory' -Verb 'Enable' -Arguments @( , [int[]] $nodeids ) | Out-Null
I changed up the query to get a list of NodeIDs based on a custom property. There are no errors but when I do a list resources, the Asset Inventory box is not checked. Can someone see if I am doing something wrong here?