2 Replies Latest reply on Mar 16, 2017 7:10 AM by nick_scott

    Remove Non Cisco Devices from UDT


      We have an issue where users will add servers into UDT.  Our methodology is to only allow access switches in UDT.  I have created the script below to identify all devices where the vendor is not Cisco.   It brings back the expected Uri's however when I add the Remove-SwisObject statement it errors out. 


      $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


      #Query Data

      $query = Get-SwisData $swis "SELECT u.uri FROM Orion.UDT.Port u JOIN Orion.Nodes n ON n.nodeid = u.nodeid WHERE n.vendor <> 'cisco'"


      # The line above does finds the Uri's below.  Which happen to be the devices I want GONE!



      # Remove Objects

      $query | Remove-SwisObject $swis


      # Error when adding $query | Remove-SwisObject $swis


      Remove-SwisObject : Operation not supported on Orion.UDT.Port
      At C:\Users\nsd000.QACMA\Documents\PowerShell Scripts\Do not Modify\Remove Non Cisco Devices From UDT.ps1:22 char:10
      + $query | Remove-SwisObject $swis
      +          ~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [Remove-SwisObject], FaultException`1
          + FullyQualifiedErrorId : SwisError,SwisPowerShell.RemoveSwisObject