Via Jeff Hicks on Twitter (https://www.twitter.com/jeffhicks), I found this post on renaming a computer using Powershell
http://newdelhipowershellusergroup.blogspot.in/2012/02/set-computer-name-using-powershell.html
I need to compare this on Monday to my work-in-progress script. This script above is probably the same as what I had found, but lacks the error correction I am still working on. What if someone enters the name '&laptop #1'? Plus, I want to account for someone entering a FQDN or just the hostname. Some ideas I was working on:
1. Check if it's a fully qualified domain name (regular expression check for hostname.something.something)
2. Quick check the hostname is valid for Windows
3. Quick check the hostname meets our server naming standards
4. Check if the DNS suffix meets our naming standards
5. Show the hostname and DNS suffix and prompt for confirmation before renaming the server
Another idea:
Require the hostname but make the DNS suffix optional, defaulting to our 'normal' DNS suffix. Similar to this:
Rename-Server -newname ServerA
would result in this type of output from the script:
Assuming default DNS suffix of mydomain.local. Please confirm is ServerA the correct hostname?
[Y] [N] [?]
But Rename-Server -newname ServerA -dnssuffix myotherdomain.local would also work.
Please confirm ServerA is the correct hostname and myotherdomain.local is the correct DNS suffix.
[Y] [N] [?]
Lots of high standards here for this script, I must remember the adage 'done is better than perfect' and have a working script that we can start using soon. I could probably spend 8 hours perfecting the regex for the Quick check if hte hostname is valid for Windows.
No comments:
Post a Comment