Learn about Windows PowerShell
Summary: Use Windows PowerShell to rename a newly created computer.
How can I use Windows PowerShell to rename a computer if I don’t know the machine name?
Use the Rename-Computer cmdlet and the built in HOSTNAME command, then reboot the computer. For example, to rename a computer to called MININT-123 to CONTOSO-FS:
RENAME-COMPUTER –computername MININT-123 –newname CONTOSO-FS
If I am not wrong, the system requires a reboot after rename to take effect. I am not sure. I tried
$PC = Get-WmiObject -Class Win32_ComputerSystem
You are absolutely correct. A reboot of the machine is required.
Now to rename the computer locally if you don't know it's name in one line.
RENAME-COMPUTER -computer name (hostname) -newname CONTOSO-FS; RESTART-COMPUTER -force
More correctly a restart is ALWAYS required after a computer is renamed, even with WMI
Yes, restart is required to effect the name change. The restart command can also be included here.
Nice sample, thanks for sharing.
On Windows 8 and above, the Rename-Computer function includes a -restart parameter so it is not necessary to also use the Restart-Computer function.
Hi All, thanks for sharing tips. I just installed Windows 8.1 - PowerShell Rocks :)
@Sean Kearney - Your code has typo
RENAME-COMPUTER -computername (hostname) -newname CONTOSO-FS; RESTART-COMPUTER -force
ComputerName "No Space"
This can be done like below
Rename-Computer -NewName PowerShell -DomainCredential Domain01\Admin01 -Restart
By default - ComputerName is localhost
Any idea what I am doing wrong with this rename command?
RENAME-COMPUTER -computername WIN-RCKIR1484MR -newname QAMPF16SPARE
The error message is The term 'RENAME-COMPUTER' is not recognized as the name of the cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:16
+ RENAME-COMPUTER < -computername="" win-rckir1484mr="" -newname="" qampf16spare="">
PowerShell V3 or later. - Users should learn how to use the Internet to look things up. All CmdLets are available by just pasting the CmdLet name into Google, Bing or Yahoo.
The first thing a hopeful Admin needs to learn is how to use the search engine. It is your pal.
Hope this helps.