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.

Discovery through SDK is no longer working as expected PowerShell

I've been working on and off on this automation tool and it used to work great on 10.6. I've recently upgraded to 11.0.1 and now my script is no longer importing WMI based nodes properly at all. I've checked to see if my variable inside the CreateCorePluginConfiguraiton is present and it appears that it is but when I look at the discovery profiles it doesn't find the test node. Also the discovery finishes incredibly quick which makes me believe that it's not handling this properly. Code for the discovery below. I still need to make this more flexable but I've not had the time to keep up on this project.

$FaultIPListImport = 0

if ($CSV)

{

#CSV import

$importFile="c:\Users\Administrator\Desktop\NodeList.csv"

$importList=IMPORT-CSV $importFile

}

else

{

$importList = $IPAddresses

}

$nodeIpList = Get-SwisData $swis "Select IPAddress from Orion.Nodes"

ForEach ($import in $importList)

{

    if ($nodeIpList -contains $import)

    {

    Write-Host "Node is already in system with IP $import"

    }

    else

    {

    $FaultIPListImport = 1

    $block = $import

   # $build = $build + "<d3p1:string>$block</d3p1:string>"

   $build = $build + "<IPAddress><Address>$block</Address></IPAddress>"

    }

}

#Logic to test for blank import list.

if ($FaultIPListImport -eq 0)

{

Write-Host "No IPs to import! All are duplicates!"

Break

}

#Output the IP List

$build

$CoreParameter = ([xml]"<CorePluginConfigurationContext xmlns:i='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://schemas.solarwinds.com/2012/Orion/Core'>

<BulkList >

$build

</BulkList>

  <Credentials>    

    <SharedCredentialInfo>

    <CredentialID>1</CredentialID>

    <Order>1</Order>

    </SharedCredentialInfo>

    <SharedCredentialInfo>

    <CredentialID>2</CredentialID>

    <Order>2</Order>

    </SharedCredentialInfo>

    <SharedCredentialInfo>

    <CredentialID>3</CredentialID>

    <Order>3</Order>

    </SharedCredentialInfo>

    <SharedCredentialInfo>

    <CredentialID>4</CredentialID>

    <Order>4</Order>

    </SharedCredentialInfo>

    <SharedCredentialInfo>

    <CredentialID>5</CredentialID>

    <Order>5</Order>

    </SharedCredentialInfo>

    <SharedCredentialInfo>

    <CredentialID>6</CredentialID>

    <Order>6</Order>

    </SharedCredentialInfo>

    <SharedCredentialInfo>

    <CredentialID>7</CredentialID>

    <Order>7</Order>

    </SharedCredentialInfo>

    <SharedCredentialInfo>

    <CredentialID>8</CredentialID>

    <Order>8</Order>

    </SharedCredentialInfo>

    <SharedCredentialInfo>

    <CredentialID>9</CredentialID>

    <Order>9</Order>

    </SharedCredentialInfo>

  </Credentials>

<WmiRetriesCount>1</WmiRetriesCount>

<WmiRetryIntervalMiliseconds>10000</WmiRetryIntervalMiliseconds>

</CorePluginConfigurationContext>").DocumentElement

$CoreConfig = Invoke-SwisVerb $swis "Orion.Discovery" "CreateCorePluginConfiguration" @($CoreParameter)

$CoreConfigInnerPiece = $coreConfig.InnerXml

$StartDiscoveryCfg = ([xml]"

<StartDiscoveryContext xmlns:i='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://schemas.solarwinds.com/2012/Orion/Core'>

  <Name>Test Discovery1</Name>

  <EngineId>1</EngineId>

  <JobTimeoutSeconds>3600</JobTimeoutSeconds>

  <SearchTimeoutMiliseconds>2000</SearchTimeoutMiliseconds>

  <SnmpTimeoutMiliseconds>3000</SnmpTimeoutMiliseconds>

  <SnmpRetries>4</SnmpRetries>

  <RepeatIntervalMiliseconds>1800000</RepeatIntervalMiliseconds>

  <SnmpPort>161</SnmpPort>

  <HopCount>0</HopCount>

  <PreferredSnmpVersion>SNMP2c</PreferredSnmpVersion>

  <DisableIcmp>false</DisableIcmp>

  <AllowDuplicateNodes>false</AllowDuplicateNodes>

  <IsAutoImport>false</IsAutoImport>

  <ImportUpInterface>false</ImportUpInterface>

  <ImportDownInterface>false</ImportDownInterface>

  <ImportShutdownInterface>false</ImportShutdownInterface>

  <IsHidden>false</IsHidden>

  <PluginConfigurations>

    <PluginConfiguration>

        <PluginConfigurationItem>$CoreConfigInnerPiece</PluginConfigurationItem>

    </PluginConfiguration>

  </PluginConfigurations>

</StartDiscoveryContext>"

).DocumentElement

$out = Invoke-SwisVerb $swis "Orion.Discovery" "StartDiscovery" @($StartDiscoveryCfg)

$output = $out.innerxml

#Once complete $output will give you the ProfileID.

$output

#Will leave in the $JobStatus loop to stall the script until the discovery is complete.

$JobStatus = Get-SwisData $swis "Select Status from Orion.DiscoveryProfiles Where ProfileID = $output"

While ($jobStatus -ne 2)

{

    Write-Host "Discovery Not Finished Yet!"

    Start-Sleep -s 10

    $JobStatus = Get-SwisData $swis "Select Status from Orion.DiscoveryProfiles Where ProfileID = $output"

}

Write-Host "Discovery has completed!"

$DiscoveryInfo = Get-SwisData $swis "select IPAddress, IPAddressGUID, NodeID, ProfileID, cred.Name, cred.ID, EngineID, HostName, Vendor from Orion.DiscoveredNodes dn

left join Orion.DiscoveryProfiles dp on dn.ProfileID = dp.ProfileID

left join Orion.Credential cred on dn.CredentialID = cred.ID

where dn.ProfileID = $output"

  • Figured something out but I'm still not sure why it's not working. I'm finding that $CoreParameter does contain the IPaddresses that I'm looking to target but as soon as it's put through the CreateCorePluginConfiguration verb it loses the IP addresses. Does that verb take XML in &gt;&lt; format or <> format? Also why would it just lose the IP addresses when I'm follow the format shown at this other post from madhaven here Re: Re: How do we programmatically discover the non-interface properties [in Orion] and enable them

  • I've been looking more at this and I'm finding something strange. In my code I can see that $CoreParameter is holding the IP address list in the $CoreParameter.BulkList.IPAddress.Address area of the object but once passed to CreateCorePluginConfiguration those IP addresses are lost. I'm inputting the IP address using Re: Re: How do we programmatically discover the non-interface properties [in Orion] and enable them and specifically the post by madhavan as a guide but it's not working. Can someone please tell me why when following the steps laid out in that post I am still unable to pass the IP addresses along? Is this another bug in the SDK?

  • That gave me the clue I needed to figure this one out. Here's the problem. XML element names are case sensitive, and your script has the casing wrong on one of them: IPAddress should be IpAddress. When I changed this line:

       $build = $build + "<IPAddress><Address>$block</Address></IPAddress>"

    To this:

       $build = $build + "<IpAddress><Address>$block</Address></IpAddress>"

    It started working. And if you look at Madhavan's post that you linked to, you will see that's how the IpAddress element is spelled there too.

    I can't say how your script could have worked in 10.6. I don't have a 10.6 installation handy to test against, but I checked the source code history for that class to see if some developer had foolishly changed the casing of that element, but it has not changed there.

  • Gah foiled by case again! It worked because I'd insert the IP addresses into the output after the fact since I still couldn't get this part to work. But now I really needed this to work as I'm making this more dynamic at pulling in all the credentials and IPs from either command line passed from automated systems or CSV for bulk adding of systems. This is getting to be an interesting companion application for sure but it's getting larger and more complicated every iteration.

    Thank you for the information. I'll verify that this is really the answer though I'm pretty sure it is.