30 Replies Latest reply on Sep 29, 2017 8:39 AM by beastroy

    API Network Discovery

    nick_scott

      Following the instructions on GitHub (Discovery · solarwinds/OrionSDK Wiki · GitHub ) I am attempting to create a very basic network scan where IP address's between 10.X.0.1-10.X.31.254 are scanned with the credential ID's provided.   I am assuming the 3 separate plugin configuration are all actually part of the same script ?  Assuming this is correct, when I run the script now, the system is expecting an argument at the line below

       

      #Error expecting argument

      PS C:\Users\nsd000.QACMA> C:\Users\nsd000.QACMA\Documents\PowerShell Scripts\Do not Modify\Discovery.ps1

       

      cmdlet Invoke-SwisVerb at command pipeline position 1

       

      Supply values for the following parameters:

       

      Arguments[0]:

       

      Invoke-SwisVerb : Verb Orion.NPM.Interfaces.CreateInterfacesPluginConfiguration requires 1 parameters not 0

       

      At C:\Discovery.ps1:73 char:34

       

      + $InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces Crea ...

       

      +                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

       

          + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

       

          + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

       

       

       

      #The error above is referencing the line directly below

      $InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces CreateInterfacesPluginConfiguration

       

      #Complete Script Below, Everything above this line is describing the problem

      #CONNECTION TO SWIS

      $ErrorActionPreference = 'Stop'

      #Add the snapin
      Add-PSSnapin SwisSnapin

      #create a connection to solarwinds

      $hostname = 'X.X.X.X'
      $username = 'X'
      $password = 'X'

      #swis = Connect-Swis -Hostanme $hostname -Trusted
      $swis = Connect-Swis -Hostname $hostname -Username $username -Password $password

       

       

      #Core Plugin Configuration

      $CorePluginConfigurationContext = ([xml]"
      <CorePluginConfigurationContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
              <IpAddressRange>
                  <StartAddress>10.X.0.1</StartAddress>
                  <EndAddress>10.X.31.254</EndAddress>
              </IpAddressRange>
          <Credentials>
              <SharedCredentialInfo>
                  <CredentialID></CredentialID>
                  <CredentialID>1</CredentialID>
               <CredentialID>2</CredentialID>
               <CredentialID>11</CredentialID>
                  <CredentialID>13</CredentialID>
                  <CredentialID>20</CredentialID>
                  <CredentialID>21</CredentialID>
               <CredentialID>47</CredentialID>
               <CredentialID>71</CredentialID>
                  <CredentialID>89</CredentialID>
                  <CredentialID>110</CredentialID>
                  <CredentialID>156</CredentialID>
                  <CredentialID>163</CredentialID>
                  <CredentialID>170</CredentialID>
               <CredentialID>197</CredentialID>
                  <CredentialID>198</CredentialID>
                  <CredentialID>202</CredentialID>
                  <Order>1</Order>
              </SharedCredentialInfo>
          </Credentials>
          <WmiRetriesCount>1</WmiRetriesCount>
          <WmiRetryIntervalMiliseconds>1000</WmiRetryIntervalMiliseconds>
      </CorePluginConfigurationContext>
      ").DocumentElement

       

      #Interface Plugin Configuration

      $CorePluginConfiguration = Invoke-SwisVerb $swis Orion.Discovery CreateCorePluginConfiguration @($CorePluginConfigurationContext

      $InterfacesPluginConfigurationContext = ([xml]"
      <InterfacesDiscoveryPluginContext xmlns='http://schemas.solarwinds.com/2008/Interfaces'
                                        xmlns:a='http://schemas.microsoft.com/2003/10/Serialization/Arrays'>
          <AutoImportStatus>
              <a:string>Up</a:string>
              <a:string>Down</a:string>
              <a:string>Shutdown</a:string>
          </AutoImportStatus>
          <AutoImportVirtualTypes>
              <a:string>Virtual</a:string>
              <a:string>Physical</a:string>
          </AutoImportVirtualTypes>
          <AutoImportVlanPortTypes>
              <a:string>Trunk</a:string>
              <a:string>Access</a:string>
              <a:string>Unknown</a:string>
          </AutoImportVlanPortTypes>
          <UseDefaults>false</UseDefaults>
      </InterfacesDiscoveryPluginContext>
      ").DocumentElement

      $InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces CreateInterfacesPluginConfiguration

       

      #Discovery Plugin Configuration

      $EngineID = 1
      $DeleteProfileAfterDiscoveryCompletes = "false"

      $StartDiscoveryContext = ([xml]"
      <StartDiscoveryContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
          <Name>Script Discovery $([DateTime]::Now)</Name>
          <EngineId>$EngineID</EngineId>
          <JobTimeoutSeconds>3600</JobTimeoutSeconds>
          <SearchTimeoutMiliseconds>2000</SearchTimeoutMiliseconds>
          <SnmpTimeoutMiliseconds>2000</SnmpTimeoutMiliseconds>
          <SnmpRetries>1</SnmpRetries>
          <RepeatIntervalMiliseconds>1500</RepeatIntervalMiliseconds>
          <SnmpPort>161</SnmpPort>
          <HopCount>0</HopCount>
          <PreferredSnmpVersion>SNMP2c</PreferredSnmpVersion>
          <DisableIcmp>false</DisableIcmp>
          <AllowDuplicateNodes>false</AllowDuplicateNodes>
          <IsAutoImport>true</IsAutoImport>
          <IsHidden>$DeleteProfileAfterDiscoveryCompletes</IsHidden>
          <PluginConfigurations>
              <PluginConfiguration>
                  <PluginConfigurationItem>$($CorePluginConfiguration.InnerXml)</PluginConfigurationItem>
                  <PluginConfigurationItem>$($InterfacesPluginConfiguration.InnerXml)</PluginConfigurationItem>
              </PluginConfiguration>
          </PluginConfigurations>
      </StartDiscoveryContext>
      ").DocumentElement)

       

      #Running The Discovery ( I get the error noted at the top regardless of the line below.  To be honest, I guessed this would be at the bottom of the script.

      $DiscoveryProfileID = (Invoke-SwisVerb $swis Orion.Discovery StartDiscovery @($StartDiscoveryContext)).InnerText

        • Re: API Network Discovery
          tdanner

          Where you have this line:

           

               $InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces CreateInterfacesPluginConfiguration

           

          It should be this instead:

           

               $InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces CreateInterfacesPluginConfiguration @($InterfacesPluginConfigurationContext)

           

          Also, right before that you have this line:

           

               $CorePluginConfiguration = Invoke-SwisVerb $swis Orion.Discovery CreateCorePluginConfiguration @($CorePluginConfigurationContext

           

          That is missing the ) at the end. Copy/paste error?

          1 of 1 people found this helpful
            • Re: API Network Discovery
              nick_scott

              Wow, thanks for the quick reply.  Yes those were copy and paste errors.  Fixing both of those has led me to my next error/question.  The error below is referencing this line

               

              $CorePluginConfiguration = Invoke-SwisVerb $swis Orion.Discovery CreateCorePluginConfiguration @($CorePluginConfigurationContext)

                                          ^

               

               

               

              PS C:\Users\nsd000.QACMA> C:\Users\nsd000.QACMA\Documents\PowerShell Scripts\Do not Modify\Discovery.ps1

               

              Invoke-SwisVerb : Verb Orion.Discovery.CreateCorePluginConfiguration cannot unpackage parameter 0 of type SolarWinds.Data.Providers.Orion.Verbs.Discovery+CorePluginConfigurationContext

               

              At C:Discovery.ps1:50 char:28

               

              + $CorePluginConfiguration = Invoke-SwisVerb $swis Orion.Discovery CreateCorePlugi ...

               

              + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

               

                  + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

               

                  + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

               

               

                • Re: API Network Discovery
                  tdanner

                  The problem might be the empty <CredentialID></CredentialID> element in $CorePluginConfigurationContext. The contents of each <CredentialID> element must be an integer.

                  1 of 1 people found this helpful
                    • Re: API Network Discovery
                      nick_scott

                      Nice find, the credential paremeter was an issue.  That has been corrected, now the script is erroring on the last line

                       

                      $DiscoveryProfileID = (Invoke-SwisVerb $swis Orion.Discovery StartDiscovery @($StartDiscoveryContext)).InnerText

                                             ^

                      PS C:\Users\nsd000.QACMA> C:\Users\nsd000.QACMA\Documents\PowerShell Scripts\Do not Modify\Discovery.ps1


                      Invoke-SwisVerb : ProvideFault failed, check fault information.

                       

                      At C:Discovery.ps1:88 char:24

                       

                      + $DiscoveryProfileID = (Invoke-SwisVerb $swis Orion.Discovery StartDiscovery @($S ...

                       

                      +                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                       

                          + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

                       

                          + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVe

                       

                       

                                                             ^

                      • Re: API Network Discovery
                        nick_scott

                        Nevermind, I think I got it (u got it).  Thanks TDANNER!!!!!!  You are the MAN!!!!

                         

                        Regards,

                         

                        Nicholas Dentry

                          • Re: API Network Discovery
                            it.sudhanshu

                            Hi Nick,

                             

                            Great Job - I tried the same script but it executed with few errors like:

                            PS C:\Program Files (x86)\Solarwinds\Orion SDK\SWQL Studio> C:\Program Files (x86)\Solarwinds\Orion SDK\SWQL Studio\discovery_test.ps1


                            Invoke-SwisVerb : Verb Orion.NPM.Interfaces.CreateInterfacesPluginConfiguration: Not found

                             

                            At C:\Program Files (x86)\Solarwinds\Orion SDK\SWQL Studio\discovery_test.ps1:76 char:34

                             

                            + $InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces Crea ...

                             

                            + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                             

                                + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

                             

                                + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

                             

                            Invoke-SwisVerb : ProvideFault failed, check fault information.

                             

                            At C:\Program Files (x86)\Solarwinds\Orion SDK\SWQL Studio\discovery_test.ps1:106 char:24

                             

                            + $DiscoveryProfileID = (Invoke-SwisVerb $swis Orion.Discovery StartDiscovery @($S ...

                             

                            +                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                             

                                + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

                             

                                + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

                             

                             

                            Can you suggest what would be the possible issues....

                             

                              • Re: API Network Discovery
                                tdanner

                                it.sudhanshu - what products/versions do you have installed?

                                1 of 1 people found this helpful
                                  • Re: API Network Discovery
                                    it.sudhanshu

                                    Npm 10.5

                                      • Re: API Network Discovery
                                        tdanner

                                        Unfortunately, that version is too old for the discovery API.

                                        1 of 1 people found this helpful
                                          • Re: API Network Discovery
                                            it.sudhanshu

                                            yes ! but when i execute the same script on my NPM 11.5.2 then  it creates a discovery profile Under sonar discovery but ending with the error in the script ..

                                             

                                            PS C:\Users\adm2Mukherj3\Desktop> C:\Users\adm2Mukherj3\Desktop\discovery_test.ps1


                                            Invoke-SwisVerb : Verb Orion.NPM.Interfaces.CreateInterfacesPluginConfiguration: Not found

                                             

                                            At C:\Users\adm2Mukherj3\Desktop\discovery_test.ps1:76 char:34

                                             

                                            + $InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces Crea ...

                                             

                                            + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                                             

                                                + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

                                             

                                                + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

                                             

                                            can you suggest

                                             

                                             

                                              • Re: API Network Discovery
                                                it.sudhanshu

                                                @here is the complete script that I run with the below errors :

                                                 

                                                #Add the snapin
                                                Add-PSSnapin SwisSnapin

                                                 

                                                #create a connection to solarwinds

                                                $hostname = 'localhost'
                                                $username = 'admin'
                                                $password = 'Welcome@12345'

                                                 

                                                #swis = Connect-Swis -Hostanme $hostname -Trusted
                                                $swis = Connect-Swis -Hostname $hostname -Username $username -Password $password

                                                 

                                                #Everything Above This Line is Strictly Related to SwisConnection

                                                $CorePluginConfigurationContext = ([xml]"
                                                <CorePluginConfigurationContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
                                                        <IpAddressRange>
                                                            <StartAddress>10.247.6.104</StartAddress>
                                                            <EndAddress>10.247.6.105</EndAddress>
                                                        </IpAddressRange>
                                                    <Credentials>
                                                        <SharedCredentialInfo>
                                                            <CredentialID>1</CredentialID>
                                                            <CredentialID>2</CredentialID>
                                                            <CredentialID>7</CredentialID>
                                                            <CredentialID>8</CredentialID>
                                                            <CredentialID>9</CredentialID>
                                                            <CredentialID>11</CredentialID>
                                                            <CredentialID>12</CredentialID>
                                                            <CredentialID>13</CredentialID>
                                                            <CredentialID>16</CredentialID>
                                                            <CredentialID>17</CredentialID>
                                                            <CredentialID>18</CredentialID>
                                                            <CredentialID>19</CredentialID>
                                                            <CredentialID>24</CredentialID>
                                                            <CredentialID>25</CredentialID>
                                                            <CredentialID>26</CredentialID>
                                                            <CredentialID>28</CredentialID>
                                                            <Order>1</Order>
                                                        </SharedCredentialInfo>
                                                    </Credentials>
                                                    <WmiRetriesCount>1</WmiRetriesCount>
                                                    <WmiRetryIntervalMiliseconds>1000</WmiRetryIntervalMiliseconds>
                                                </CorePluginConfigurationContext>
                                                ").DocumentElement

                                                $CorePluginConfiguration = Invoke-SwisVerb $swis Orion.Discovery CreateCorePluginConfiguration @($CorePluginConfigurationContext)

                                                $InterfacesPluginConfigurationContext = ([xml]"
                                                <InterfacesDiscoveryPluginContext xmlns='http://schemas.solarwinds.com/2008/Interfaces'
                                                                                  xmlns:a='http://schemas.microsoft.com/2003/10/Serialization/Arrays'>
                                                    <AutoImportStatus>
                                                        <a:string>Up</a:string>
                                                        <a:string>Down</a:string>
                                                        <a:string>Shutdown</a:string>
                                                    </AutoImportStatus>
                                                    <AutoImportVirtualTypes>
                                                        <a:string>Virtual</a:string>
                                                        <a:string>Physical</a:string>
                                                    </AutoImportVirtualTypes>
                                                    <AutoImportVlanPortTypes>
                                                        <a:string>Trunk</a:string>
                                                        <a:string>Access</a:string>
                                                        <a:string>Unknown</a:string>
                                                    </AutoImportVlanPortTypes>
                                                    <UseDefaults>False</UseDefaults>
                                                </InterfacesDiscoveryPluginContext>
                                                ").DocumentElement

                                                $InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces CreateInterfacesPluginConfiguration @($InterfacesPluginConfigurationContext)

                                                $EngineID = 6
                                                $DeleteProfileAfterDiscoveryCompletes = "false"

                                                $StartDiscoveryContext = ([xml]"
                                                <StartDiscoveryContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
                                                    <Name> NODEADD_Automated_Discovery_test $([DateTime]::Now)</Name>
                                                    <EngineId>6</EngineId>
                                                    <JobTimeoutSeconds>3600</JobTimeoutSeconds>
                                                    <SearchTimeoutMiliseconds>2500</SearchTimeoutMiliseconds>
                                                    <SnmpTimeoutMiliseconds>2500</SnmpTimeoutMiliseconds>
                                                    <SnmpRetries>1</SnmpRetries>
                                                    <RepeatIntervalMiliseconds>2500</RepeatIntervalMiliseconds>
                                                    <SnmpPort>161</SnmpPort>
                                                    <HopCount>0</HopCount>
                                                    <PreferredSnmpVersion>SNMP2c</PreferredSnmpVersion>
                                                    <DisableIcmp>false</DisableIcmp>
                                                    <AllowDuplicateNodes>false</AllowDuplicateNodes>
                                                    <IsAutoImport>TRUE</IsAutoImport>
                                                    <IsHidden>false</IsHidden>
                                                    <PluginConfigurations>
                                                        <PluginConfiguration>
                                                            <PluginConfigurationItem>$($CorePluginConfiguration.InnerXml)</PluginConfigurationItem>
                                                            <PluginConfigurationItem>$($InterfacesPluginConfiguration.InnerXml)</PluginConfigurationItem>
                                                        </PluginConfiguration>
                                                    </PluginConfigurations>
                                                </StartDiscoveryContext>
                                                ").DocumentElement

                                                $DiscoveryProfileID = (Invoke-SwisVerb $swis Orion.Discovery StartDiscovery @($StartDiscoveryContext)).InnerText

                                                 

                                                 

                                                 

                                                 

                                                 

                                                 

                                                 

                                                Errors::

                                                ------------------------------------------------------------------------------------------------------------------------------------------------

                                                PS C:\Users\adm2Mukherj3\Desktop> C:\Users\adm2Mukherj3\Desktop\discovery_test.ps1


                                                Invoke-SwisVerb : Verb Orion.NPM.Interfaces.CreateInterfacesPluginConfiguration: Not found

                                                 

                                                At C:\Users\adm2Mukherj3\Desktop\discovery_test.ps1:62 char:34

                                                 

                                                + $InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces Crea ...

                                                 

                                                + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                                                 

                                                    + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

                                                 

                                                    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

                                                 

                                                Invoke-SwisVerb : Verb Orion.Discovery.StartDiscovery cannot unpackage parameter 0

                                                 

                                                At C:\Users\adm2Mukherj3\Desktop\discovery_test.ps1:92 char:24

                                                 

                                                + $DiscoveryProfileID = (Invoke-SwisVerb $swis Orion.Discovery StartDiscovery @($S ...

                                                 

                                                +                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                                                 

                                                    + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

                                                 

                                                    + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

                                              • Re: API Network Discovery
                                                it.sudhanshu

                                                2 more questions  -

                                                 

                                                Question1 : Can i pass the Ip range from a text file <notepad1.txt> and execute the script .

                                                 

                                                Question 2 : how to tweak the scripts when i have to use the SNMPv3  polling.

                                                  • Re: API Network Discovery
                                                    tdanner

                                                    1. You can't pass a text file for the IP range, but you can read the text file in PowerShell and use the values in it to build the discovery objects.

                                                    2. There's nothing special to change in this script for SNMPv3 polling. Just make sure you are providing the appropriate CredentialIDs for your saved SNMPv3 credential sets.

                                            • Re: API Network Discovery
                                              nick_scott

                                              Did you modify these two lines ?

                                               

                                                          <StartAddress>x.x.168.1</StartAddress>

                                                          <EndAddress>X.x.168.250</EndAddress>

                                               

                                              I mentioned in the last post these would need modification.  Off to lunch GL my friend

                                          • Re: API Network Discovery
                                            nick_scott

                                            The script runs as expected, what I cant figure out is why nothing is being returned.  I see the job "Run" and "Finish" in the UI.  When looking at the Discovery table, I see the various jobs kickoff and "Finish".  I made sure I only scanned networks where devices were located, specifically devices already in this instance of SolarWinds.   Another strange issue is that when set AutoImport to true it says if found two devices.  When attempting to see what those are nothing is returned.  In the snippet below you will see AutoImport and a result of 2.  In this particular SolarWinds instance there are two different polling engines, both have been used in the script.

                                             

                                             

                                            Complete Script below

                                             

                                            $ErrorActionPreference = 'Stop'

                                             

                                            #Add the snapin
                                            Add-PSSnapin SwisSnapin

                                             

                                            #create a connection to solarwinds

                                            $hostname = 'X'
                                            $username = 'X'
                                            $password = 'X'

                                             

                                            #swis = Connect-Swis -Hostanme $hostname -Trusted
                                            $swis = Connect-Swis -Hostname $hostname -Username $username -Password $password

                                             

                                            #Everything Above This Line is Strictly Related to SwisConnection

                                            $CorePluginConfigurationContext = ([xml]"
                                            <CorePluginConfigurationContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
                                                    <IpAddressRange>
                                                        <StartAddress>10.X.139.1</StartAddress>
                                                        <EndAddress>10.X.169.254</EndAddress>
                                                    </IpAddressRange>
                                                <Credentials>
                                                    <SharedCredentialInfo>
                                                        <CredentialID>1</CredentialID>
                                                        <CredentialID>2</CredentialID>
                                                        <CredentialID>7</CredentialID>
                                                        <CredentialID>8</CredentialID>
                                                        <CredentialID>9</CredentialID>
                                                        <CredentialID>11</CredentialID>
                                                        <CredentialID>12</CredentialID>
                                                        <CredentialID>13</CredentialID>
                                                        <CredentialID>16</CredentialID>
                                                        <CredentialID>17</CredentialID>
                                                        <CredentialID>18</CredentialID>
                                                        <CredentialID>19</CredentialID>
                                                        <CredentialID>24</CredentialID>
                                                        <CredentialID>25</CredentialID>
                                                        <CredentialID>26</CredentialID>
                                                        <CredentialID>28</CredentialID>
                                                        <Order>1</Order>
                                                    </SharedCredentialInfo>
                                                </Credentials>
                                                <WmiRetriesCount>1</WmiRetriesCount>
                                                <WmiRetryIntervalMiliseconds>1000</WmiRetryIntervalMiliseconds>
                                            </CorePluginConfigurationContext>
                                            ").DocumentElement

                                            $CorePluginConfiguration = Invoke-SwisVerb $swis Orion.Discovery CreateCorePluginConfiguration @($CorePluginConfigurationContext)

                                            $InterfacesPluginConfigurationContext = ([xml]"
                                            <InterfacesDiscoveryPluginContext xmlns='http://schemas.solarwinds.com/2008/Interfaces'
                                                                              xmlns:a='http://schemas.microsoft.com/2003/10/Serialization/Arrays'>
                                                <AutoImportStatus>
                                                    <a:string>Up</a:string>
                                                    <a:string>Down</a:string>
                                                    <a:string>Shutdown</a:string>
                                                </AutoImportStatus>
                                                <AutoImportVirtualTypes>
                                                    <a:string>Virtual</a:string>
                                                    <a:string>Physical</a:string>
                                                </AutoImportVirtualTypes>
                                                <AutoImportVlanPortTypes>
                                                    <a:string>Trunk</a:string>
                                                    <a:string>Access</a:string>
                                                    <a:string>Unknown</a:string>
                                                </AutoImportVlanPortTypes>
                                                <UseDefaults>false</UseDefaults>
                                            </InterfacesDiscoveryPluginContext>
                                            ").DocumentElement

                                            $InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces CreateInterfacesPluginConfiguration @($InterfacesPluginConfigurationContext)

                                            $EngineID = 2
                                            $DeleteProfileAfterDiscoveryCompletes = "false"

                                            $StartDiscoveryContext = ([xml]"
                                            <StartDiscoveryContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
                                                <Name> Test $([DateTime]::Now)</Name>
                                                <EngineId>$EngineID</EngineId>
                                                <JobTimeoutSeconds>3600</JobTimeoutSeconds>
                                                <SearchTimeoutMiliseconds>2500</SearchTimeoutMiliseconds>
                                                <SnmpTimeoutMiliseconds>2500</SnmpTimeoutMiliseconds>
                                                <SnmpRetries>1</SnmpRetries>
                                                <RepeatIntervalMiliseconds>2500</RepeatIntervalMiliseconds>
                                                <SnmpPort>161</SnmpPort>
                                                <HopCount>0</HopCount>
                                                <PreferredSnmpVersion>SNMP2c</PreferredSnmpVersion>
                                                <DisableIcmp>false</DisableIcmp>
                                                <AllowDuplicateNodes>false</AllowDuplicateNodes>
                                                <IsAutoImport>true</IsAutoImport>
                                                <IsHidden>false</IsHidden>
                                                <PluginConfigurations>
                                                    <PluginConfiguration>
                                                        <PluginConfigurationItem>$($CorePluginConfiguration.InnerXml)</PluginConfigurationItem>
                                                        <PluginConfigurationItem>$($InterfacesPluginConfiguration.InnerXml)</PluginConfigurationItem>
                                                    </PluginConfiguration>
                                                </PluginConfigurations>
                                            </StartDiscoveryContext>
                                            ").DocumentElement

                                            $DiscoveryProfileID = (Invoke-SwisVerb $swis Orion.Discovery StartDiscovery @($StartDiscoveryContext)).InnerText

                                      • Re: API Network Discovery
                                        nick_scott

                                        Got the scans working.  Below is my entire working script.  Now, I need to figure out how to schedule them (in script below, you will have to define start, and end address)  Thanks again TDANNER!

                                         

                                        $ErrorActionPreference = 'Stop'

                                        #Add the snapin
                                        Add-PSSnapin SwisSnapin

                                        #create a connection to solarwinds

                                        $hostname = 'X'
                                        $username = 'X'
                                        $password = 'X'

                                        #swis = Connect-Swis -Hostanme $hostname -Trusted
                                        $swis = Connect-Swis -Hostname $hostname -Username $username -Password $password

                                        #Everything Above This Line is Strictly Related to SwisConnection

                                         

                                        $CorePluginConfigurationContext = ([xml]"
                                        <CorePluginConfigurationContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
                                            <IpRanges>
                                                <IpAddressRange>
                                                    <StartAddress>x.x.168.1</StartAddress>
                                                    <EndAddress>X.x.168.250</EndAddress>
                                                </IpAddressRange>
                                            </IpRanges>
                                            <Credentials>
                                                <SharedCredentialInfo>
                                                    <CredentialID>1</CredentialID>
                                                    <CredentialID>2</CredentialID>
                                                    <CredentialID>7</CredentialID>
                                                    <CredentialID>8</CredentialID>
                                                    <CredentialID>9</CredentialID>
                                                    <CredentialID>11</CredentialID>
                                                    <Order>1</Order>
                                                </SharedCredentialInfo>
                                            </Credentials>
                                            <WmiRetriesCount>1</WmiRetriesCount>
                                            <WmiRetryIntervalMiliseconds>1000</WmiRetryIntervalMiliseconds>
                                        </CorePluginConfigurationContext>
                                        ").DocumentElement

                                        $CorePluginConfiguration = Invoke-SwisVerb $swis Orion.Discovery CreateCorePluginConfiguration @($CorePluginConfigurationContext)

                                        $InterfacesPluginConfigurationContext = ([xml]"
                                        <InterfacesDiscoveryPluginContext xmlns='http://schemas.solarwinds.com/2008/Interfaces'
                                                                          xmlns:a='http://schemas.microsoft.com/2003/10/Serialization/Arrays'>
                                            <AutoImportStatus>
                                                <a:string>Up</a:string>
                                                <a:string>Down</a:string>
                                                <a:string>Shutdown</a:string>
                                            </AutoImportStatus>
                                            <AutoImportVirtualTypes>
                                                <a:string>Virtual</a:string>
                                                <a:string>Physical</a:string>
                                            </AutoImportVirtualTypes>
                                            <AutoImportVlanPortTypes>
                                                <a:string>Trunk</a:string>
                                                <a:string>Access</a:string>
                                                <a:string>Unknown</a:string>
                                            </AutoImportVlanPortTypes>
                                            <UseDefaults>false</UseDefaults>
                                        </InterfacesDiscoveryPluginContext>
                                        ").DocumentElement

                                        $InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces CreateInterfacesPluginConfiguration @($InterfacesPluginConfigurationContext)

                                        $EngineID = 2
                                        $DeleteProfileAfterDiscoveryCompletes = "false"

                                        $StartDiscoveryContext = ([xml]"
                                        <StartDiscoveryContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
                                            <Name> Test $([DateTime]::Now)</Name>
                                            <EngineId>$EngineID</EngineId>
                                            <JobTimeoutSeconds>3600</JobTimeoutSeconds>
                                            <SearchTimeoutMiliseconds>2500</SearchTimeoutMiliseconds>
                                            <SnmpTimeoutMiliseconds>2500</SnmpTimeoutMiliseconds>
                                            <SnmpRetries>1</SnmpRetries>
                                            <RepeatIntervalMiliseconds>2500</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>
                                                    <PluginConfigurationItem>$($InterfacesPluginConfiguration.InnerXml)</PluginConfigurationItem>
                                                </PluginConfiguration>
                                            </PluginConfigurations>
                                        </StartDiscoveryContext>
                                        ").DocumentElement

                                        $DiscoveryProfileID = (Invoke-SwisVerb $swis Orion.Discovery StartDiscovery @($StartDiscoveryContext)).InnerText

                                        • Re: API Network Discovery
                                          beastroy

                                          nick_scott, tdanner Thank you for this post! This information has been extremely helpful!

                                           

                                          I'm not sure if this has been answered somewhere else, but do you have any recommendations on how to accomplish the following:

                                          • Remove "Topology: Layer 3" from the monitored resources (this resource is selected by default)
                                          • Modify the volumes that are being monitored, for example, only selecting C: & D: drives when importing node (currently, it selects all discovered volumes)
                                          • Remove certain interfaces from monitoring based on the name of the interface, for example, removing Loopback interfaces and any interfaces with 'QOS' in the name
                                            • Is this something that can be accomplished using NPM.DiscoverAndAddInterfacesOnNode.ps1? After the initial discovery, we could then run another discovery and remove any unwanted interfaces from monitoring?

                                           

                                          Thanks again for your help with this!!

                                           

                                          -Troy

                                            • Re: API Network Discovery
                                              nick_scott

                                              Hi Troy glad to of helped a little. In all honesty I would of gotten no where without the community and more specifically Tdanner.   In regards to API discovery I never implemented in prod.  The inability to schedule was a deal breaker for me.   I'm not sure how big your envirment it, but large ones in my experience can get really beat up by too many un-optimized scans.  If your wanting to remove/disclude certain interfaces and volumes it may be easiest to whack them once the API discovery is completed.  The script below queries for volumes based on their descriptions.  You then invoke the Remove command to delete them.  This script could be re-worked with just about any interface, node, or volume.  You could also set this up as a recurring job within the Server OS.  Let me know if this helps. 

                                               

                                              $ErrorActionPreference = 'Stop'

                                              #Add the snapin
                                              Add-PSSnapin SwisSnapin

                                              #create a connection to solarwinds

                                              $hostname = 'XXX'
                                              $username = 'XXX'
                                              $password = 'XXX'

                                              #swis = Connect-Swis -Hostanme $hostname -Trusted
                                              $swis = Connect-Swis -Hostname $hostname -Username $username -Password $password

                                              #Query = variable, GetSwis

                                              $query = Get-SwisData $swis "Select uri FROM Orion.volumes WHERE VolumeDescription LIKE 'P:\%' OR VolumeDescription = '/TMP'"

                                              # Remove Objects  THE LINE BELOW MUST BE UN_COMMENTEd IN ORdER FOR THIS SCRIPT TO DO ANYTHING

                                              #$query | Remove-SwisObject $swis

                                              # Before removing anything view the query results by running the script as is
                                              $query

                                              1 of 1 people found this helpful
                                              • Re: API Network Discovery
                                                tomas.vrabel

                                                Regarding removal of Topology resource:

                                                Topology resource is represented by poller assigned to node.

                                                 

                                                You can list monitored nodes with assigned topology poller using this SWQL query:

                                                SELECT PollerID, Uri, PollerType, NetObject, NetObjectType, NetObjectID, Enabled

                                                FROM Orion.Pollers

                                                where PollerType like '%Topology%'

                                                 

                                                NetObject contains entity type (N = Nodes ) and related entity ID (e.g. NodeID).

                                                Example: N:1 is node with NodeId=1

                                                 

                                                Poller URI can be used to disable the poller for given node.

                                                This Python script worked for me:

                                                    
                                                    swis = SwisClient(npm_server, username, password)
                                                   
                                                    # 'N.Topology_Layer3.SNMP.ipNetToMedia': False,
                                                    pollerUri = 'swis://brn-dvb-tvra-02.swdev.local/Orion/Orion.Pollers/PollerID=84'
                                                    swis.update(pollerUri, Enabled = False)
                                                

                                                 

                                                 

                                                1 of 1 people found this helpful
                                                  • Re: API Network Discovery
                                                    beastroy

                                                    Thanks again tomas.vrabel! We are using PowerShell and I was able to accomplish this using the following code:

                                                     

                                                    $topologyURI = Get-SwisData $swis "SELECT Uri FROM Orion.Pollers WHERE PollerType LIKE '%Topology%' AND NetObjectID=@nodeID" @{ nodeID =$nodeID}

                                                     

                                                    Set-SwisObject -SwisConnection $swis -Uri $topologyURI -Properties @{Enabled = 0}

                                                     

                                                    Your input helped me reach this solution much faster. Thank you!

                                                     

                                                    -Troy

                                                  • Re: API Network Discovery
                                                    tomas.vrabel

                                                    Regarding filtering of interfaces.

                                                    You can approach it two different ways

                                                    1) Using SWIS verb and leveraging script orionsdk-python/discover_and_add_interfaces.py at master · solarwinds/orionsdk-python · GitHub

                                                    See Re: REST Delete/BulkDelete Operations for Orion.NPM.DiscoveredInterfaces/Orion.DiscoveredVolumes

                                                     

                                                    2) Remove interface after they imported to Orion as nick_scott suggested above

                                                     

                                                    Unfortunately Orion SDK does not support ignoring interfaces or volumes in discovery process.

                                                    1 of 1 people found this helpful
                                                    • Re: API Network Discovery
                                                      beastroy

                                                      Thanks for the information and quick response nick_scott, tomas.vrabel !!

                                                       

                                                      This is extremely helpful!!

                                                      • Re: API Network Discovery
                                                        beastroy

                                                        I've noticed whenever we add the node via the API Discovery, the node is also being managed by NCM.

                                                         

                                                        Is there a way to unmanage the node from NCM either during the discovery or after it is added?

                                                         

                                                        -Troy

                                                          • Re: API Network Discovery
                                                            tomas.vrabel

                                                            Seems like discovered Orion nodes are automatically added to NCM during discovery.

                                                            Which plugins and configuration do you provide to discovery profile in your discovery script? Could you please share you script?

                                                            E.g. NcmDiscoveryPlugin add discovered nodes to NCM, you can try to remove it from you discovery profile configuration if it's included currenlty

                                                             

                                                            You can also remove nodes from NCM using SWIS verbs:

                                                            Cirrus.Nodes.RemoveNode

                                                            Cirrus.Nodes.RemoveNodes

                                                             

                                                            As parameter you need to provide NCM nodeId (different from Orion nodeId).

                                                            Mapping between NCM nodeID and Orion nodeID can be retrieve from Cirrus.Nodes entity:

                                                            select NodeId from Cirrus.Nodes where CoreNodeId=2

                                                             

                                                            Example script:

                                                                swis = SwisClient(npm_server, username, password)  
                                                                ncmNodeId = 'a69521e1-6b0f-418a-849e-30e30e1a3e19'
                                                                swis.invoke('Cirrus.Nodes', 'RemoveNode', ncmNodeId)
                                                                print("NCM node removed")
                                                            
                                                            
                                                            

                                                            If it will not work for you please post your script and I will try to help.

                                                             

                                                            There are many SWIS verbs that can help you to manage NCM nodes, verbs can be found under Cirrus.Nodes entity (AddNode, RemoveNode, UpdateNode)

                                                            1 of 1 people found this helpful
                                                              • Re: API Network Discovery
                                                                beastroy

                                                                Thanks so much tomas.vrabel! This information was very helpful. I was able to accomplish this in PowerShell using the following code:

                                                                 

                                                                $coreNodeID = Get-SwisData $swis "SELECT NodeId FROM Cirrus.Nodes WHERE CoreNodeId=$nodeID"

                                                                 

                                                                Invoke-SwisVerb $swis Cirrus.Nodes RemoveNode $coreNodeID

                                                                 

                                                                Thank you for your help!!