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

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

    It takes effect after reboot .

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

    See U