PS C:> wmic computersystem where name=`"$env:computername`" call rename `"new-computer-name"
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
ReturnValue = 0;
};
This strange syntax ("…") is necessary in Powershell to quote the ", and the " are necessary if the the computername has special characters such as hyphens.
After executing this command, the system needs to be rebooted for the change to take effect.