Jump to content

Rename-Computer


AMC

Recommended Posts

Hi Folks,

 

I'm new to Pulsewau scripting, please bear with me.

I've tried to run the following PowerShell command, but it doesnt seem to run.

Rename-Computer -NewName "Computer123" -DomainCredential MyDomain\Administrator -Restart

Any advice on what I should do, to rename a computer?

Link to comment
Share on other sites

  • Administrators

Hi @AMC,

Based on the documentation, the DomainCredential parameter says:

Quote

If you type a user name, this cmdlet prompts you for a password.

We run PowerShell in a non-interactive mode, this prevents inputs from being triggered. You can provide a PSCredential object instead of the username and that should do the trick.

$password = "ThisIsAPlaintextPassword" | ConvertTo-SecureString -asPlainText -Force
$username = "contoso\Administrator"
[PSCredential] $credential = New-Object System.Management.Automation.PSCredential($username, $password)
Rename-Computer -NewName "NewComputerName" -DomainCredential $credential -Restart

-Paul

Link to comment
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
×
×
  • Create New...