-
-
Save timnew/2373475 to your computer and use it in GitHub Desktop.
$ComputerName = "New Name" | |
Remove-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -name "Hostname" | |
Remove-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -name "NV Hostname" | |
Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\Computername\Computername" -name "Computername" -value $ComputerName | |
Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\Computername\ActiveComputername" -name "Computername" -value $ComputerName | |
Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -name "Hostname" -value $ComputerName | |
Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -name "NV Hostname" -value $ComputerName | |
Set-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -name "AltDefaultDomainName" -value $ComputerName | |
Set-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -name "DefaultDomainName" -value $ComputerName |
FYI I had the issue that I needed a name change without reboot AND running PsExec for another user session on the same machine afterwards. I got this Error: Creating key file on $newComputername. The user name or password is incorrect / The network location cannot be reached.
Fix was to add the following lines to rename.ps1
# Restart service to have PsExec working after name change; wait 5 seconds to be safe
Restart-Service Server -Force
Start-Sleep
So I found this script and thought it would be awesome. The script does rename the computer and it looks good from that end, but in AD, the name does not update. This causes issue with SCCM and other management tools. I ended up renaming them the old fashioned way but with Powershell that prompts me for my AD PW.
So I found this script and thought it would be awesome. The script does rename the computer and it looks good from that end, but in AD, the name does not update. This causes issue with SCCM and other management tools. I ended up renaming them the old fashioned way but with Powershell that prompts me for my AD PW.
That makes sense; you can't just change a name in Active Directory without authentication. That system is completely separate from the local machine.
EDIT: More simply and best