Powershell provides a command to rename a Windows computer. Here are the steps.

Steps to rename your computer using powershell (with a prompt)
- Open Powershell as Administrator
- Open Windows start menu
- Type powershell
- Right-click on the Powershell app icon and select Run as Administrator
- Once your Powershell window is opened as admin, run the command: Rename-Computer
Rename-Computer
- When prompted for the new name, provide your preferred computer name
- After renaming the computer, you would need to restart the computer to take the changes into effect.
You may use the same Powershell command in a script to do the same task, providing you have properly captured the parameters and restart.