Links

Rename Multiple Computers

A Custom Script to rename multiple computers using a hash table and rebooting after imaging.

PowerShell Script

The following is the Rename Multiple Computers sample PowerShell script. Copy it and save it as a .ps1 file. For further information on hosting this script see Quick Guide to Self-Hosting Custom Scripts.
$namelist= ConvertFrom-StringData -StringData $args[0]
if ($namelist.ContainsKey($env:computername)) {
Rename-Computer -NewName $namelist[$env:computername] -Force -Restart
}

Custom Script Settings

The table below outlines all the fields that need to be set when creating this custom script.
For a detailed guide, refer to Create a Rename Multiple Computers Custom Script.
Field
Value
Name
Rename Computers with Hash Table and Reboot
URL
Type
PowerShell
Command-Line
Enter the name of the computer and the name to change it to separating the with the = symbol, each entry on a new line, using the format "ComputerNameFrom=ComputerNameTo" <Enter> used as line separator e.g.
"DT23432_23r=DESKTOP1
DESKTOP353=DESKTOP2
LENOVO2154=LAPTOP1"
Run As
System Account or Specified User Account

Optional Changes to Make to the PowerShell Script

The following change is optional, download the script from http://www.faronics.org/rename_reboot_hash.ps1, make your changes, then host it (this will change the URL in step 6 below). See the Quick Guide to Self-Hosting Custom Scripts for more information.
Change Description
Change
Reboots Instantly after Rename.
Remove -Force -Restart from the script to prevent an instant restart.

How to Create a Custom Script to Rename Multiple Computers

Create a Custom Script
1. Select the Control Grid tab on the top menu bar.
2. Navigate to the Applications tab.
3. Click CUSTOM SCRIPT.
4. Select Create Custom Script.
5. Enter a Name for the script, Rename Computers with Hash Table and Reboot in this example; use any name you'd like to use.
Create Custom Script to Rename Computers with Hash Table and Reboot
6. Enter the URL that points to the hosted script http://www.faronics.org/rename_reboot_hash.ps1 in this example. You might need to download this file and host it on a link that is whitelisted in your firewall.
Best Practice is to download the sample script and self-host it. You can do this for free with GitHub. See the Quick Guide to Self-Hosting Custom Scripts for more information.
7. Select the script type: Powershell.
8. Command Line: Enter the computers' names that you wish to rename together with the new name, separating the current name and new name with an = symbol. Each pair of names must be on a new line using <enter> as a line separator.
e.g. "ComputerNameFrom=ComputerNameTo" <Enter>
The following is an example of three computers being renamed:
Renaming 3 Computers
9. Select the account to Run As; either System Account or Specified User Account.
10. Click SAVE TO GRID.
Once saved, the script can be pushed to an individual computer or groups of computers. It can also be scheduled using a Policy.
For a guide on how to run your custom script, see Pushing the Script.
The script will now appear in the list of Custom Scripts. It will also be available to select from the Applications Control Grid View.
Search for the script in the grid using the search option. If your applications are grouped, you will see a column named Custom Scripts. Selecting the Custom Script header will display all the scripts that have been added to the grid.