We have a large environment where over time certain polling engines will aquire more nodes than others. In the past I have monthly/quartly re-assigned these nodes to their correct polling engines manually via GUI. Because we use SolarWinds for asset inventory the scan jobs must be up to date. I only have polling engines scan networks where that polling engines devices live. This way I don't get a bunch of "changed" notices via discovery. From my understanding a polling engine during a discovery will think it found new/changed devices even if that device is managed by another polling engine.
The objective of the script is to place nodes based on their IP to a specific polling engine. at the end of the script I added a clause that excludes devices who are already on the correct polling engine. I do not want the app to set the EngineId if already correct (And EngineID <> 2)
If I run the script with the two arguments below (WHERE ip_address LIKE '10.22.%' AND EngineId <> '2'" ) The script does what its suppose to do. It only applies the engine change if the queried node is not already on the specified engine.
$uris=Get-SwisData$swis"SELECT uri FROM Orion.Nodes WHERE ip_address LIKE '10.22.%' AND EngineId <> '2'"
As soon as I add another argument such as another IP filter, the script ignores the last argument EngineId <> 2
$uris=Get-SwisData$swis"SELECT uri FROM Orion.Nodes WHERE ip_address LIKE '10.22.%' OR ip_address LIKE '10.210.%' AND EngineId <> '2'"
I'm thinking I am missing a small piece of syntax, any help is greatly appreciated. As always, a big thanks to the SDK veterans, you really do make all this possible. Thanks!
Full script below (security removed)
$ErrorActionPreference = 'Stop'
#Add the snapin
Add-PSSnapin SwisSnapin
#create a connection to solarwinds
#swis = Connect-Swis -Hostanme $hostname -Trusted
$swis = Connect-Swis -Hostname $hostname -Username $username -Password $password
$targetEngineId =@{ EngineId = 3; }
$uris = Get-SwisData $swis "SELECT uri FROM Orion.Nodes WHERE ip_address LIKE '10.22.%' OR ip_address LIKE '10.210.%' AND EngineId <> '2'"
$uris | Set-SwisObject $swis -properties $targetEngineId