7

I am the system admin for a small business (120 employees) and I am looking at an easy way to rename all of the computers in the office to a more uniform naming convention.

I have tried playing with the "netdom renamecomputer" line in command prompt but that doesn't seem to work at all. Possibly because are not on a Group Policy. We set our computers up using a WORKGROUP and then have our employees connect to work servers using Remote Desktop connections.

Is there a Powershell tool or a program that i can download to help me rename all the computers in our network?

P.S. we have mostly Win7 machines but recently we have added about 20 Win8 machines (in case that matters)

4 Answers 4

16

I haven't used this myself, but a quick google brings this command back a lot

WMIC ComputerSystem where Name=COMPUTERNAME call Rename Name=NewName

If the computer name has dashes or other special characters you need to quote the computer name

WMIC ComputerSystem where Name="COMPUTER-NAME" call Rename Name=NewName

Source

4
  • Thank you so much Bali C. I had tried that a few times but to no avail. The problem was that i needed to put the " " in. Now, i just need to figure out how to do this remotely from my PC so i wont have to create a batch file and run it on everyone's computer. Jan 29, 2013 at 18:11
  • Use PSExec.exe to execute wmic remotely. You can download psexec from sysinternals, here: technet.microsoft.com/en-US/sysinternals/bb897553.aspx
    – Mark Allen
    Jan 29, 2013 at 21:37
  • @MaylorTaylor No worries :) As Mark suggested, use psexec, that will work well.
    – Bali C
    Jan 30, 2013 at 9:30
  • 2
    For bonus ease of use, use the %COMPUTERNAME% environment variable for querying for the old name.
    – mroach
    Aug 1, 2013 at 22:44
6

Powershell 3.0 (Windows 8) introduced the Rename-Computer cmdlet. Example:

Rename-Computer -NewName NewComputerName -Restart

This will rename the computer and immediately restart.

TechNet Documentation.

1
  • Great. I remember hostname binary used to work too. Now it seems only to get the %computername%.
    – user373230
    Jul 7, 2017 at 6:13
3

In powershell you can use something similar to Bali's, but I would use powershell's get-wmiobject function instead, but this does the same thing. The difference is that the powershell cmdlets can be called remotely if need be (though you would have to configure your environment for psremoting, well worth it imo), plus you wouldn't have to worry about passing credentials through like you do w/ PSExec (try mapping a drive under diff creds remotely w/ psexec!), anyway, the command would be

PS C:\Users\admin> $(gwmi win32_computersystem).Rename("Bldg-SerialNum")

and this could even be automated by grabbing the serial # of the machine from wmi also, so you could either deploy your .ps1 scripts to each machine or run a single script from your own machine that grabs each machine name from a list, connects to it, gets the serial number, and changes the name accordingly.

0

PS C:\Users\admin> (gwmi win32_computersystem).Rename("addspdc01")

works for me!!! thx a lot @MDMoore313

also, not sure why but this also works:

PS rename-computer addspdc01 -localcredential:admin -domaincredential:admin

2
  • Avoid posting answers to old questions that already have well received answers unless you have something substantial and new to add.
    – Toto
    Mar 28, 2023 at 8:37
  • Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review Mar 28, 2023 at 8:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .