Requirements
Script
# connect to SolarWinds$Hostname = "localhost"$Username = "admin"$Password = ""$swis = Connect-Swis -Hostname $Hostname -Username $Username -Password $Password# set default values for AWS profile and regionSet-AWSCredential -ProfileName MyNewProfileSet-DefaultAWSRegion -Region us-east-2# list of tags to sync$tags = "Environment", "Owner"# gather all instance IDs$instanceIDs = @()$reservations = Get-EC2Instanceforeach($res in $reservations) { foreach($inst in $res.Instances) { $instanceIDs += $inst.InstanceId }}# iterate through the list of instance IDsforeach ($instanceID in $instanceIDs) { # get the tag values for this instance $tagValues = Get-EC2Tag -Filter @{Name="resource-id";Values=$instanceID}, @{Name="key";Values=$tags} # get the custom properties for the corresponding node $node = Get-SwisData $swis "SELECT Nodes.NodeID , CP.Uri , CP.Environment , CP.Owner FROM Orion.Nodes AS Nodes LEFT JOIN Orion.Cloud.Aws.Instances AS Instances ON Nodes.NodeID = Instances.NodeID LEFT JOIN Orion.NodesCustomProperties AS CP ON Nodes.NodeID = CP.NodeID WHERE InstanceId = '$($instanceID)'" # update the value for each custom property if needed foreach($tag in $tagValues) { # check if the custom property is empty if(!$node.($tag.Key)) { # if it is empty, update it with the AWS tag value $props = @{ ($tag.Key) = $tag.Value; } Set-SwisObject $swis -Uri $node.Uri -Properties $props } }}-anazurc
Loop1 Systems: SolarWinds Training and Professional Services