Hi everyone,
I already added the device as ICMP via Network Sonar Wizard. Unfortunately, the hostname is the same with the IP Address. How can I change multiple device hostnames?
Hi everyone,
I already added the device as ICMP via Network Sonar Wizard. Unfortunately, the hostname is the same with the IP Address. How can I change multiple device hostnames?
To do it via powershell use this OrionSDK/Samples/PowerShell/Update.Captions.ps1 at master · solarwinds/OrionSDK · GitHub
Also see this for doing it using SQL (+) Bulk Node Name/Caption Change - Forum - Network Performance Monitor (NPM) - THWACK (solarwinds.com)
You could use a custom property or you can load a CSV.
# Build Connection to SWIS - SolarWinds Platform $SwisHost = <host> # Connection to host $swisConnection = Connect-Swis -Hostname $SwisHost -Certificate # The actual SWIS query $Query = "SELECT N.Caption, N.CustomProperties._Nickname AS NickName, N.IP_Address, N.Uri FROM Orion.Nodes N WHERE N.Caption != N.CustomProperties._Nickname;" # <> N.CustomProperties._NicknameNS $nodes = Get-SwisData -SwisConnection $swisConnection -Query $query $nodes | Foreach-Object { Write-Output "Renaming node $($_.IP_Address), $($_.Caption) to $($_.NickName)" if($($_.NickName) -like 'NotAvailable') { Set-SwisObject -SwisConnection $swisConnection -Uri $_.URI -Properties @{ Caption=$($_.IP_Address) }} # uncomment the lines below if you're seeing the output you expect above # else { # Set-SwisObject -SwisConnection $swisConnection -Uri $_.URI -Properties @{ Caption=$($_.NickName) } } }
OR
# Build Connection to SWIS - SolarWinds Platform $SwisHost = <hostname> # $SwisCreds = Get-Credential -Message "Enter the username/password for '$SwisHost'" #$SwisConnection = Connect-Swis -Hostname $SwisHost -Credential $SwisCreds $SwisConnection = Connect-Swis -Hostname $SwisHost -Username <username> -Password <Password> Write-Host "Reading data from E:\WIP\inventory.csv" $csv = Import-Csv "E:\WIP\inventory.csv" -Delimiter ';' $csv | ForEach-Object { $Caption = $_.Nickname $IP_Address = $_.IPAddress $query = " SELECT Nodes.Caption, Nodes.URI FROM Orion.Nodes Where IPAddress Like '$IP_Address' " $nodes = Get-SwisData -SwisConnection $swisConnection -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 $swisConnection -Uri $node.URI -Properties @{ "Caption" = $newName } } }
You could use a custom property or you can load a CSV.
# Build Connection to SWIS - SolarWinds Platform $SwisHost = <host> # Connection to host $swisConnection = Connect-Swis -Hostname $SwisHost -Certificate # The actual SWIS query $Query = "SELECT N.Caption, N.CustomProperties._Nickname AS NickName, N.IP_Address, N.Uri FROM Orion.Nodes N WHERE N.Caption != N.CustomProperties._Nickname;" # <> N.CustomProperties._NicknameNS $nodes = Get-SwisData -SwisConnection $swisConnection -Query $query $nodes | Foreach-Object { Write-Output "Renaming node $($_.IP_Address), $($_.Caption) to $($_.NickName)" if($($_.NickName) -like 'NotAvailable') { Set-SwisObject -SwisConnection $swisConnection -Uri $_.URI -Properties @{ Caption=$($_.IP_Address) }} # uncomment the lines below if you're seeing the output you expect above # else { # Set-SwisObject -SwisConnection $swisConnection -Uri $_.URI -Properties @{ Caption=$($_.NickName) } } }
OR
# Build Connection to SWIS - SolarWinds Platform $SwisHost = <hostname> # $SwisCreds = Get-Credential -Message "Enter the username/password for '$SwisHost'" #$SwisConnection = Connect-Swis -Hostname $SwisHost -Credential $SwisCreds $SwisConnection = Connect-Swis -Hostname $SwisHost -Username <username> -Password <Password> Write-Host "Reading data from E:\WIP\inventory.csv" $csv = Import-Csv "E:\WIP\inventory.csv" -Delimiter ';' $csv | ForEach-Object { $Caption = $_.Nickname $IP_Address = $_.IPAddress $query = " SELECT Nodes.Caption, Nodes.URI FROM Orion.Nodes Where IPAddress Like '$IP_Address' " $nodes = Get-SwisData -SwisConnection $swisConnection -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 $swisConnection -Uri $node.URI -Properties @{ "Caption" = $newName } } }
Thank you so much
SolarWinds solutions are rooted in our deep connection to our user base in the THWACK® online community. More than 200,000 members are here to solve problems, share technology and best practices, and directly contribute to our product development process.