Hi Folks,
I am trying to accomplish solarwinds node rediscovery process via SWIS. if i want to run the rediscovery for single/few nodes then it is running completely fine with below script.
$username = "xxxx" $password = ConvertTo-SecureString "xxxxx" -AsPlainText -Force $creds = New-Object System.Management.Automation.PSCredential ($username, $password) $swis = Connect-Swis -Credential $creds -Hostname polling_server_name $CorePluginConfigurationContext = ([xml]" <CorePluginConfigurationContext xmlns:i='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://schemas.solarwinds.com/2012/Orion/Core'> <BulkList> <IpAddress> <Address>10.72.14.72</Address> </IpAddress> <IpAddress> <Address>10.72.156.33</Address> </IpAddress> </BulkList> <Credentials> <SharedCredentialInfo> <CredentialID>28</CredentialID> <Order>1</Order> </SharedCredentialInfo> <SharedCredentialInfo> <CredentialID>20</CredentialID> <Order>2</Order> </SharedCredentialInfo> </Credentials> <WmiRetriesCount>1</WmiRetriesCount> <WmiRetryIntervalMiliseconds>1000</WmiRetryIntervalMiliseconds> </CorePluginConfigurationContext> ").DocumentElement $CorePluginConfiguration = Invoke-SwisVerb $swis Orion.Discovery CreateCorePluginConfiguration @($CorePluginConfigurationContext) $EngineID = 1 $DeleteProfileAfterDiscoveryCompletes = "false" $StartDiscoveryContext = ([xml]" <StartDiscoveryContext xmlns:i='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://schemas.solarwinds.com/2012/Orion/Core'> <Name>Script Discovery $([DateTime]::Now)</Name> <EngineId>$EngineID</EngineId> <JobTimeoutSeconds>3600</JobTimeoutSeconds> <SearchTimeoutMiliseconds>2500</SearchTimeoutMiliseconds> <SnmpTimeoutMiliseconds>2500</SnmpTimeoutMiliseconds> <SnmpRetries>1</SnmpRetries> <RepeatIntervalMiliseconds>2500000</RepeatIntervalMiliseconds> <SnmpPort>161</SnmpPort> <HopCount>0</HopCount> <PreferredSnmpVersion>SNMP2c</PreferredSnmpVersion> <DisableIcmp>false</DisableIcmp> <AllowDuplicateNodes>false</AllowDuplicateNodes> <IsAutoImport>false</IsAutoImport> <IsHidden>false</IsHidden> <PluginConfigurations> <PluginConfiguration> <PluginConfigurationItem>$($CorePluginConfiguration.InnerXml)</PluginConfigurationItem> </PluginConfiguration> </PluginConfigurations> </StartDiscoveryContext> ").DocumentElement $DiscoveryProfileID = ( Invoke-SwisVerb $swis Orion.Discovery StartDiscovery @($StartDiscoveryContext) ).InnerText Write-Verbose "$(Get-Date -Format 'dd/MM/yyyy HH:mm:ss'):`t DISCOVERY profile #$DiscoveryProfileID running..." # WAIT until the discovery completes do { Write-Host -NoNewline "." Start-Sleep -Seconds 1 $Status = Get-SwisData $swis "SELECT Status FROM Orion.DiscoveryProfiles WHERE ProfileID = @profileId" @{profileId = $DiscoveryProfileID } } while ($Status -eq 1) $Result = Get-SwisData $swis "SELECT Result, ResultDescription, ErrorMessage, BatchID FROM Orion.DiscoveryLogs WHERE ProfileID = @profileId" @{profileId = $DiscoveryProfileID } # PRINT the outcome switch ($Result.Result) { 1 { "InProgress" } 2 { "Finished" } 3 { "Error" } 4 { "NotScheduled" } 5 { "Scheduled" } 6 { "NotCompleted" } 7 { "Canceling" } 8 { "ReadyForImport" } } $Result.ResultDescription $Result.ErrorMessage
However, if i want to provide a moduler solution to admins to trigger rediscovery on particular polling engine for all its associated Nodes, then i am following below steps:
- Connect to SWIS and feed step 2,3,4 info into above script.
- Find the engine ID
- All the nodes which are getting polled by that Engine ID
- All credential info which is associated with the particular Node.
- then rest of below XML thing.
Currently I am unable to feed all the info into the above script. Any help related to the same will be helpful, kindly assist.