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.

Update address custom property from sitename custom property

Hi

I have over 1000 objects in my Orion setup all of which have a custom property called SiteName which is a dropdown list of site names.

I would like to auto populate an address field inc postcode from this SiteName field.

Is it possible to do this using either powershell or SDK on a script? Maybe it runs every 30 mins to catch people changing the SiteName field on an object.

Thanks

Richard

  • Hi Richard,

    Just to clarify are you looking for the node custom property "SiteName" to automatically populate data into another node custom property called "SiteAddress"?

  • you can definitely do this via script/PowerShell. depending on the complexity of the ask, you may even look at the alert action to update custom properties and build this inside of orion itself.

    for powershell; it would be something similar to this, set the a scheduled task, I'd imagine (sorry for the brevity, I'm on mobile right now)

    Start-Transcript -Path <logfile location>
    Import-Module SwisPowerShell
    $reference = Import-Csv -Path <Path to source csv with sitenames and address information>
    $swis = <build SWIS connection>
    $query = "SELECT NodeID, Caption, SiteName From Orion.NodesCustomProperties"
    $data = Get-SwisData -SwisConnection $swis -Query $query
    foreach( $d in $data ) {
      foreach ( $r in $reference ) {
          if( $d.siteName -eq $r.siteName ) {
                $cp = @{ SiteAddress = $( $r.siteAddress ); }
                $uri = "swis://localhost/Orion/Orion.Nodes/NodeID=$($d.NodeID)/CustomProperties
                Set-SwisObject -SwisConnection $swis -Uri $uri -Properties $cp
                Write-Host "NODEID: $($d.NodeID)`nCAPTION: $($d.Caption)`nSITENAME: $( $d.SiteName)`nADDRESS: $($r.SiteAddress)`n"
          }  
      }
    }
    Stop-Transcript

    This is very high level, but logically sound. I'm sure there are other paths to join the 2 data sets together as well that others might chime in with. I would definitely recommend setting up some internal standards on logging and error handling as well so you can easily troubleshoot if/when things go a little sideways down the line.

    *** This is heavily referenced in OrionSDK/CRUD.SettingCustomProperty.ps1 at master · solarwinds/OrionSDK · GitHub  and TC18: Creating and Updating Orion Custom Properties with PowerShell

  • I would check the Alert Option, you often forget about your SDK Scripts once they are running smoothly and you don’t do excessive Scripting. Without knowing the deeper details this should be perfectly doable with the builtin alerts.