Category filter
PowerShell script to rename Windows devices
As an IT administrator, there could be several reasons why you might want to rename your Windows devices. For instance, you might want to assign familiar and identifiable device names that adhere to your organization’s asset naming convention. Hexnode enables administrators to rename Windows devices on multiple devices using custom scripts simultaneously.
Rename Windows devices
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
param( [string] $deviceName ) try{ if($deviceName) { Write-Host "Changing device name to:"$deviceName Rename-Computer -NewName $deviceName } else { Write-Host "Please provide device name as argument" } } catch { Write-Host $_.Exception.Message } |
When executing the script, pass the device name to be assigned to the device as Arguments. You can also pass the argument using the wildcards supported by Hexnode, which can be very convenient when simultaneously deploying the script to multiple devices in bulk.
For example, provide the argument as %assettag% to change the device name to its asset tag number as provided in the device summary page in the Hexnode portal.
If a wildcard contains a string of words, passing it as an argument will take in the characters until the first space character. To pass the entire string of words associated, the wildcard should be specified as an argument enclosed in double quotes.
For instance, if the value of the wildcard %assettag% is Macbook Air, then passing it as an argument will only take in the first word Macbook. Whereas, enclosing %assettag% in double quotes will capture the entire string Macbook Air.