PowerShell Scripts - Rename Local computer name and restart

This script  will take affect after restart

 
$NewName="windowsserver"
$ComputerInfo = Get-WmiObject -Class Win32_ComputerSystem
$ComputerInfo.Rename($NewName)
Restart-Computer

Comments

  • Anonymous
    April 20, 2016
    after i ran the command i got the error message ReturnValue: 5. the user is added in local administrator group.