Command Prompt:
netdom renamecomputer Thecomputernamehere /newname:newnamehere /force /userd:domain\username /passwordd:***** /reboot
Powershell:
Example 1: Rename the local computer
This command renames the local computer to Server044 and then restarts it to make the change effective.
PowerShell
Rename-Computer -NewName "Server044" -DomainCredential Domain01\Admin01 -Restart
Example 2: Rename a remote computer
This command renames the Srv01 computer to Server001. The computer is not restarted.
The DomainCredential parameter specifies the credentials of a user who has permission to rename computers in the domain.
The Force parameter suppresses the confirmation prompt.
PowerShell
Rename-Computer -ComputerName "Srv01" -NewName "Server001" -DomainCredential Domain01\Admin01 -Force