This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Looking for a example or help on how to update worldmap (lat.lon) via powershell and swis

The only example I have seen is a PERL example.  Looking for something similar but using PowerShell.  I plan on combining that with a few other parts I already created.  In the end I plan to create groups with a dynamic query.  Then select the InstanceId once the group is created and update the worldmap (lat\lon) so I can autogenerate the world map with our 400-500 locations.  

props = {

        'Instance': 'Orion.Nodes',

        'InstanceId': 343,

        'Latitude': 38.889963929167,

        'Longitude': -77.027206420898


    results = swis.create('Orion.WorldMap.Point', **props)

Thanks in advance if anyone can help out.

  • I definitely think you can do it via PowerShell, but is there a reason you aren't just populating latitude / longitude on the group or node directly and letting Orion auto add the nodes?

    Needless to say I haven't tried this via Powershell. If powershell is the way to go, my gut says New-SwisObject will be the command you are looking for, maybe this script points you in the right direction:

  • Thanks,

    If there is another way to do it I'm 2100% open to it.  

    So your saying if I add LAT\LON on the group Orion will auto add it on the world map, if I understood you correctly?

  • I've done this in a couple of different ways in the past.

    The first was manually, using Place nodes automatically on the Worldwide Map in the Orion Platform ( as a base.

    If you don't want to use those type of "location" elements from SNMP (and I didn't because I preferred my Windows Servers use the "Site" name from Active Directory), you can update them with a PowerShell Script.

    $SwisHost = ""
    $SwisUsername = "admin"
    $SwisPassword = "This is not a legit password"
    $SwisConnection = Connect-Swis -Hostname $SwisHost -UserName $SwisUsername -Password $SwisPassword
    $Swql = @"
    SELECT [Nodes].NodeID
         , [Nodes].IPAddress
         , [Nodes].Caption
         , [Nodes].InstanceType
         , [Nodes].Location -- From SNMP's sysLocation
         , [Nodes].WorldMapPoint.AutoAdded AS [AutoAdded]
         , [Nodes].WorldMapPoint.Latitude AS [Latitude]
         , [Nodes].WorldMapPoint.Longitude AS [Longitude]
         , [Nodes].WorldMapPoint.StreetAddress AS [StreetAddress]
         , [Nodes].WorldMapPoint.Uri AS [MapNodeUri]
    FROM Orion.Nodes AS [Nodes]
    $NodesLocations = Get-SwisData -SwisConnection $SwisConnection -Query $Swql
    # Results of this should be (mostly) empty for Lat/Long
    # This is a simple example:
    # For all nodes what have a "location" of "Office", set the Lat/Long to something
    $NodesToUpdate = $NodesLocations | Where-Object { $_.Location -eq "Office" }
    # Cycle through each Node in the $NodesToUpdate list
    ForEach ( $Node in $NodesToUpdate ) {
        if ( $Node.MapNodeUri ) {
            # if the MapNodeUri exists already, then we delete it
            # (IMHO) This is the best way to avoid duplicate entries in the WorldMap table
            Remove-SwisObject -SwisConnection $SwisConnection -Uri $Node.MapNodeUri
        # Create a new map point
        $PropertiesToCreate = @{
            AutoAdded = 'False'; # Since you are manually setting this, it's false
            Latitude = 37.23999; # I just randomly selected some numbers
            Longitude = -95.89204; # I just randomly selected some numbers
            Instance = $Node.InstanceType; # mandatory - the "Orion" type, like Orion.Nodes or Orion.NPM.Interfaces
            InstanceID = $Node.NodeID # mandatory - the ID of the thing above (Node, Interface, etc.)
        Write-Host "Creating Map Entry for $( $Node.Caption ) [$( $Node.IPAddress )] with Lat/Long: $($PropertiesToCreate["Latitude"] )/$($PropertiesToCreate["Longitude"] )"
        New-SwisObject -SwisConnection $SwisConnection -EntityType 'Orion.WorldMap.Point' -Properties $PropertiesToCreate
        # Done creating/updating this specific node - move on to the next

    I have not tested this outside my lab, but it seems to work ok here.

  • Thank you!

    This is what I was looking for!

  • And as stated, you can do the same thing for Orion Groups or other elements.

  • I'll share what I was able to piece together incase anyone else ever needs to do the same.

    Import-Module SwisPowerShell

    $groupList=IMPORT-CSV $importFile

    $SwisHost = ""
    $SwisUsername = "admin"
    $SwisPassword = "FAKE PASSWORD"

    $SwisConnection = Connect-Swis -Hostname $SwisHost -UserName $SwisUsername -Password $SwisPassword

    Foreach ($group in $grouplist)
    $SiteCode = $group.SiteCode
    $Lat = $group.Lat
    $Lon = $group.Lon

    $members = @(
    @{ Name = "$SiteCode"; Definition = "filter:/Orion.Nodes[Contains(Caption,'$SiteCode')]" })

    $groupId = (Invoke-SwisVerb $SwisConnection "Orion.Container" "CreateContainer" @("$SiteCode","Core",60,0,"Store","true",

    # group members
    "<ArrayOfMemberDefinitionInfo xmlns='">'>",
    [string]($members |% {

    $Swql = @"
    SELECT [Groups].ContainerID

    FROM Orion.Groups AS [Groups]
    WHERE [Groups].Name = '$SiteCode'
    $GroupsLocations = Get-SwisData -SwisConnection $SwisConnection -Query $Swql
    # Results of this should be (mostly) empty for Lat/Long

    $PropertiesToCreate = @{
    AutoAdded = 'True';
    Latitude = $Lat;
    Longitude = $Lon;
    Instance = 'Orion.Groups';
    InstanceID = $GroupsLocations

    New-SwisObject -SwisConnection $SwisConnection -EntityType 'Orion.WorldMap.Point' -Properties $PropertiesToCreate

  • Unfortunately, your long URLs were truncated because you didn't include your script in a "code" block.

    From that pop-up, you can choose "PowerShell" from the list of languages.