Jump to content
captainu99

Rename A Computer Script

Recommended Posts

Something so simple is giving me a huge headache.

I would like to create a script that renames a computer and then prompts the user to reboot/Reboots

Any Advice?

 

 

No matter what I select "Powershell" or "Powershell as admin"

Powershell Command - Rename-computer –newname “@NewComputerName@”

 

Error

Rename-computer : Fail to rename computer 'currentcomputername' to 'newcomputername' due to the following exception: Access is 
denied.
At line:1 char:1
+ Rename-computer -newname "WLK-WS-UM1"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (WIL-WS-UM1:String) [Rename-Computer], InvalidOperationException
    + FullyQualifiedErrorId : FailToRenameComputer,Microsoft.PowerShell.Commands.RenameComputerCommand

 

RenameComputerScript.PNG

Share this post


Link to post
Share on other sites

Its not labtech, its the machine.  Make sure you have creds that are correct, you could also attempt to rename with CMD

Share this post


Link to post
Share on other sites
1 minute ago, kspooner said:

Its not labtech, its the machine.  Make sure you have creds that are correct, you could also attempt to rename with CMD

I figured so.

Any insight into a command to use that won't require credentials?

Share this post


Link to post
Share on other sites

I have a working script, you need to use Shell (NOT AS ADMIN) so it runs with administrative rights on the computer, you will have to pass domain credentials to the command so that the computer can join to the domain successfully. I'll sanitize the script (if its not already) and then upload it here. You will only be able to use it with the versions of powershell that include the Rename-Computer. Alternatively you can search around on the forums here @DarrenWhite99 has a script that doesn't use Powershell and is very reliable.

Share this post


Link to post
Share on other sites

Found it, its completely generalized and pulls domain credentials from the Default Credentials configured on the location. This script comes with EDFs so make sure you rename the tabs on the computer to whatever you want or you'll have "IntelliComp" tabs lying around :)

 

Computer Name Change scheduled at 2am.xml

  • Thanks 1

Share this post


Link to post
Share on other sites

@MGreen Thank you. I will read through it. (BTW: A server cant work if its unplugged 🙂)

For now, my script works with powershell 3.0 "Rename-Computer" 

Whats the best way for me to check if a computer has powershell 3.0 installed?

Also what command do I need in order for Autoamte to show the correct computer name? I thought it was "Resend System Information" yet it still shows the old computer name in automate.

 

Edited by captainu99

Share this post


Link to post
Share on other sites

Very nice! Look at the downloads area of The Geek, I think @DarrenWhite99 posted a custom defined role for PowerShell versions? There are also plugins like @Cubert Powershell and .NET plugin that you can purchase which will maintain the versions for you and keep them up-to-date. You can also design your own; you'll have to create monitors or run scripts to extract the version from the Registry and download the update files and run them on a schedule. Keep in mind certain softwares are not always compatible with the latest versions of .NET so that gets a little tricky.

Nice job with the server ;)

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×