Batch scripting is not dead
There’s still a little place in my heart for a decent batch script. This morsel prompts the user to enter a new computer name and then, using NETDOM, it renames the computer on the domain securely prompting for the password of an account with the required privileges. Use it in a deployment if you aren’t able or willing to use WDS’ built-in Client Naming Policy and prefer not to end up with PC-RT4T5FGR8HY or something equally ridiculous.
1 2 3 4 5 6 7 8 9 |
@ECHO OFF ECHO. ECHO This computer is currently named: %COMPUTERNAME% ECHO. SET /P TARGETNAME=Enter a new computer name: ECHO. ECHO The computer will be renamed to: %TARGETNAME% NETDOM RENAMECOMPUTER %COMPUTERNAME% /NewName:%TARGETNAME% /UserD:[Administrator] /PasswordD:* /SecurePasswordPrompt /Reboot:15 PAUSE |
I’d love to see a PowerShell example that queries a bespoke database for a unique computer name, applies it to the computer and marks it as used in the database – a little project perhaps…?
-Lewis