1. Using WMI
WMIC computersystem where caption='currentname' rename newname
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\administrator>wmic computersystem where caption='OLDNAME' rename NEWNAME
Executing (\\F204\ROOT\CIMV2:Win32_ComputerSystem.Name="F204")->rename()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
ReturnValue = 0;
};
C:\Users\administrator>
If the renaming operation is succesful ReturnValue = 0; if there is an error you will get an error code.
2. Using PS
Enter-Pssession (before)
Rename-Computer -NewName "NewName" -DomainCredential Domain01\Admin01 -Restart