Renaming computers via command prompt

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)


Solution 1:

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

Solution 2:

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.

Solution 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.