PowerShell Scripts – Rename Local computer name and restart


This script  will take affect after restart

[sourcecode language="powershell"]
$NewName="windowsserver"
$ComputerInfo = Get-WmiObject -Class Win32_ComputerSystem
$ComputerInfo.Rename($NewName)
Restart-Computer

[/sourcecode]
Comments (1)

  1. Vikas Shah says:

    after i ran the command i got the error message ReturnValue: 5. the user is added in local administrator group.