I have seen a few requests on 'how to bulk edit captions' and had to do it myself today so sharing the script I used. The script originated from here: OrionSDK/Update.Captions.ps1 at master · solarwinds/OrionSDK · GitHub
You will need to have a directory structure C:\PowershellScripts\UpdateCaptions\
in place. Copy the script there (or modify it for your own directory) giving it whatever name you wish .ps1. You will also need to place a .csv file named NewCaptions.csv in the same directory. The csv file should contain columns named IP_Address containing IP's and captions in a column named caption.
as shown, mine has some additional columns, which is not a problem the script will only read the ones in yellow. Or if you are comfortable with PowerShell you can modify the script to your own column names.
You will need to replace the line $swis = Connect-Swis -host YOURORIONSERVER -Trusted with you own Orion server name. The script is also using -Trusted
so it will run as your current ID so if you need to run a different authentication method change those to your own preference.
As shown the script has the line that does the actual change commented out with a #, do run it 'as is' first and verify the changes look correct before uncommenting out the #Set-SwisObject -SwisConnection $swis -Uri $node.URI -Properties @{ "Caption" = $newName }
which will make the change to the database
Remember to run this is a test environment and verify everything is working prior to running in your production environment.
Read the comments at the top and throughout the script before running
# This code originated from https://github.com/solarwinds/OrionSDK/blob/master/Samples/PowerShell/Update.Captions.ps1
# Put Your Orion Server or IP as shown in all caps $swis = Connect-Swis -host YOURORIONSERVERHERE -Trusted
# This will run as the user you are currently logged in to your workstation as, make sure you have admin on Orion with your credentials, otherwise change the script to your preferred authentication method
# Copy script into C:\PowershellScripts\UpdateCaptions directory it needs to run from there
# You need to have a CSV file containing your IP's in a column named IP_Address and captions in a column named Caption for the script to read them
# The CSV may contain additional columns, the script will only read the IP_Address and Caption column
# The csv file needs to use this name and be in this path C:\PowershellScripts\UpdateCaptions\NewCaptions.csv
# Run the script once first to verify all names are as you expect them if they look good then uncomment out the line below that states Set-SwisObject -SwisConnection $swis -Uri $node.URI -Properties @{ "Caption" = $newName }
# to make the actual changes to the database
# Test this code in a test instance before using in your production environment
cls
cd c:\powershellscripts
Write-Host "Loading Solarwinds Plug in"
Import-Module -Name SwisPowerShell
Add-PSSnapin SwisSnapin
Write-host "This script will import custom properties from C:\PowershellScripts\ImportCustomProperties\ImportFile.csv"
# Change the line below to your orion server name or IP the -trusted option will use your currently logged in ID
$swis = Connect-Swis -host YOURORIONSERVERHERE -Trusted
Write-Host "Reading data from C:\PowershellScripts\UpdateCaptions\NewCaptions.csv"
$csv = Import-Csv C:\PowershellScripts\UpdateCaptions\NewCaptions.csv
$csv | ForEach-Object {
$Caption = $_.Caption
$IP_Address = $_.IP_Address
$query = "
SELECT Nodes.Caption, Nodes.URI FROM Orion.Nodes Where IPAddress Like '$IP_Address'
"
$nodes = Get-SwisData -SwisConnection $swis -Query $query
foreach ($node in $nodes) {
$newName = $Caption
# skip over this node if it already has the right name
if ($node.Caption -ceq $newName) {
continue
}
Write-Output "Renaming node $IP_Address, $($node.Caption) to $newName"
# uncomment the line below if you're seeing the output you expect above
#Set-SwisObject -SwisConnection $swis -Uri $node.URI -Properties @{ "Caption" = $newName }
}
}
Exit (0)