What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags

View all Tags

Change Device Name Using Script



Hi Guys,

Need your expertise on this matter. Currently I got over 500 devices need to change the device name that meaningful for end-user. I'm thinking about to create a batch script to change all that device name in one shot.

Any idea?

Thanks in advance.

batch device-name script

Created on Aug 23, 2017 3:34:47 AM

2 Replies



Hi there,

I encourage you to have a look here:

The same idea applies, but for a different field/property.

Best Regards,
Luciano Lingnau [Paessler Support]

Created on Aug 23, 2017 5:36:12 AM by  Luciano Lingnau [Paessler]



For anyone looking for an example of how to change the name of hundreds of devices using powershell:

    [Parameter(Mandatory=$false)][string]$Uri = 'https://prtg.example.org',
	[Parameter(Mandatory=$false)][string]$UserName = 'llingnau',
	[Parameter(Mandatory=$false)][string]$Passhash = '123456789',
	[int]$Timeout = "10"

$b = Invoke-WebRequest -Uri "$($Uri)/api/table.xml?content=devices&output=xml&columns=objid,name,host&id=0&username=$($UserName)&passhash=$($Passhash)" -TimeoutSec $Timeout -UseBasicParsing -ErrorAction SilentlyContinue
$xml = [xml]$b.Content

$nodes = $xml.SelectNodes("//item")

foreach ($node in $nodes) {

    Write-Output "Parsing: $($node.name)"
    $a = Invoke-WebRequest -Uri "$($Uri)/api/rename.htm?id=$($node.objid)&value=$($node.name.Replace('olddomain.tld','newdomain.tld'))&username=$($UserName)&passhash=$($Passhash)" -TimeoutSec $Timeout -UseBasicParsing -ErrorAction SilentlyContinue

This is the minimum example to make this work and obviously comes with no support whatsoever.

The use-case for this script was renaming devices to a different tld, so from "device.olddomain.tld" to "newdomain.tld" (for demonstrations purposes). Obviously doing only this is a bad idea because it would mean you have device names that no longer match the configured addresses which would lead to some confusion, but the point of the script is showing a very simple way of updating device names, one could now extend the script to adjust any other property available to devices.

Line 8 will simply query all devices (up to 500, which can be increased with the limit parameter)

And the loop in lines 13-17 will set a new name based on the content of $($node.name) - In this particular case, doing the Replace('olddomain.tld','newdomain.tld') to change part of the name.

There's no error validation and the script will also try to update the name of names that haven't changed, which isn't ideal but works for a proof of concept of interacting with the API. Ideally one would only do the /api/rename call for object's who's names actually changed.

Best Regards,
Luciano Lingnau [Paessler]

Created on Jul 5, 2022 8:59:46 AM by  Luciano Lingnau [Paessler]

Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.