I am writing a PowerShell script using Rename-Computer and I am facing an odd problem:
PS C: \ Users \ Administrator> Rename-Computer -NewName 395_s2
Rename computer: skip computer "ztest" with the new name "395_s2" because the new name is not valid. The new computer name you entered is not formatted correctly. Standard names can contain letters (az, AZ), numbers (0-9) and hyphens (-), but not spaces or periods (.). The name can not only consist of numbers and should not exceed 63 characters.
I would prefer to use underscores in machine names, and the -Force flag does not change the result.
When I enter the same name manually in the menu "Computer" - "System Properties" - "Computer Name / Domain Changes", he asks:
Do you want to use this computer name?
The name "395_s2" contains non-standard characters. This may cause problems with some applications or network equipment.
I have the option to select yes and override non-standard characters. Is there a way to do this right in PowerShell?
source
share