Summary: Scripting Games Advanced Event 6: Dr. Scripto needs to configure virtual core servers and join them to the domain.
Microsoft Scripting Guy, Ed Wilson, is here. Today is the revealing of the final event for the 2013 Scripting Games. I hope you have learned tons from this year’s games and had fun too. Remember that you need to go to www.powershell.org to submit your event. Good luck!
The Core Configurator
Dr. Scripto has just one final challenge for you: to get out alive!
No, wait…that was when Bond was over for tea and crumpets last week.
Ah, here we go…
Dr. Scripto is deploying a bunch of new virtual machines on a Server Core installation of Windows Server 2012. The virtual machines already have the operating system installed, and the local Administrator password is set to P@ssw0rd. The virtual machines are using DHCP to get an IP address. There is a DHCP server on the network named DHCP1, and it has a single DHCP scope named 10.0.0.0. The virtual machines’ current computer names are not known, and they do not yet belong to the domain.
You need to write a Windows PowerShell tool that accepts MAC addresses from the pipeline (as strings). Dr. Scripto has some files listing the virtual machines’ MAC addresses that join the virtual machines to the domain and gives them a new computer name. Your tool needs to:
- Query the Server Core installation’s current dynamic IP address from the DHCP server.
- Join each Server Core installation to the Company.local domain. Use the domain credential Admin, with the password P@ssw0rd, to join the computer to the domain. At the same time, rename the computer. The first computer should be named SERVER1, the second SERVER2, and so forth. Allow the computer to restart.
Your tool should accept a parameter for the server base name, and that should default to SERVER. With the default, the server names will be SERVER1, SERVER2, and so on. But, if someone runs the tool and specifies FRED as the server base name, then you rename the servers to FRED1, FRED2, and so on. You can assume none of the server names exist on the network. (If they do, it’s not your fault if something breaks.)
You should minimize the number of “Are you sure?” prompts that are shown while your script runs. The computers should be added to the domain’s default container for new machine objects.
It’s fine if you do this for one computer at a time, but when your script finishes running, all of the computers must be properly provisioned.
You can safely assume that SERVER1, SERVER2, and so on do not already exist in the domain.
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Ed Wilson, Microsoft Scripting Guy