Rename Computer Script?

Does anyone have a script that can rename a computer via Syncro?

I’ve tried multiple times but just cannot get it to work. The script output says access is denied even though it’s running as System and I’ve also tried feeding it admin credentials.

The script works OK in Windows but once it’s run through Syncro it doesn’t work.


I stole this from @isaacg. He has probably refined it since, but it still works for me.

Import-Module $env:SyncroModule -WarningAction SilentlyContinue
# Check if computer is domain joined
if ((Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain) {
$username = (Get-WmiObject Win32_ComputerSystem).Domain+"\$IfDomainEnterDomainAdminUsername"
$password = ConvertTo-SecureString -String "$IfDomainEnterDomainAdminPassword" -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $password
Rename-Computer -NewName "$NewName" -DomainCredential $credential
else {
Rename-Computer -newname "$NewName"
# Update Syncro's registry key
Set-ItemProperty -Path HKLM:\SOFTWARE\WOW6432Node\RepairTech\Syncro -Name "OwnerName" -Value "$NewName"
# Restart the computer for rename to take effect
if ($RestartAfterRename -eq 'Yes') {
shutdown -r -t 30

1 Like

A very similar script is already in the community script library. Saves you the trouble of setting up all the Syncro variables.


I genuinely have no idea why if I run this…

 Rename-Computer -newname "New Name"

Via Syncro terminal or via a script It gives me an access denied yet when I run that script it works?

Anyway, I’ll not bother trying to figure that out thanks very much for your help folks!!