I'm writing a PowerShell script using Rename-Computer, and I'm hitting an odd issue:
PS C:\Users\Administrator> Rename-Computer -NewName 395_s2
Rename-Computer : Skip computer 'ztest' with new name '395_s2' because the new name is not valid. The new computer name entered is not properly formatted. Standard names may contain letters (a-z, A-Z), numbers (0-9), and hyphens (-), but no spaces or periods (.). The name may not consist entirely of digits, and may not be longer than 63 characters.
I would really prefer to be able to use underscores in the machine names, and the -Force flag doesn't change the output.
When I enter the same name manually in Computer->System Properties->Computer Name/Domain Changes, it asks:
Do you want to use this computer name?
The name "395_s2" contains non-standard characters. This might cause problems with some applications or network hardware.
I have the option to choose yes and override the non-standard characters. Is there a way to do this directly in PowerShell?