Jump to content
Pulseway 9.14 🔥

Featured Replies

Posted

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?

  • 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

Create an account or sign in to comment