Change hostname via powershell

Your PowerGUI Community: Simplify your PowerShell related GUI and script editing needs.


Change hostname via powershell

This question is not answered

I have googled and googled..


How do you change the host name on a server via powershell? 

Thank you
Glen

All Replies
  • Check the Rename() method of the win32_computersystem wmi class.

    Message was edited by: Shay Levy
  • Hello,

    As shay Levy said, use wmi like that :
    $NewComputerName = "MyNewName"
    $computerinfo = Get-WmiObject -class win32_computersystem
    $computerinfo.Rename($NewComputerName)

    It takes effect after reboot .

    Take care, I m not sure if on active directory the name will be changed.

    See U
    Sylv1