2012 Scripting Games Advanced Event 8: Enable Network Adapters
Summary: In Advanced Event 8, you are required to enable and disable network adapters.
About this event
Date of Event
4/11/2012 12:01 AM
4/18/2012 12:01 AM
You are a network consultant. As a result, you travel extensively. Your main computer is your laptop. At times, you may use a wireless network adapter to connect to wireless networks. When you are using wireless, you disable the wired network connection. And at times, you use a wired network connection—when you use a wired network connection you disable the wireless network adapter. You do this to prevent bridging. Currently you use the graphical interface, and it seems to take nearly five minutes to make these changes. You would like to use Windows PowerShell to toggle your network connections. Your task in this scenario is to write a simple Windows PowerShell command to disable all enabled network connections, and enable all disabled network connections. The default output from running the script is sufficient.
- This task requires admin rights; therefore, your script should check to ensure that it is running as an admin. If the script is not launched with proper credentials, display a message that admin rights are required.
- For the purposes of this scenario, you want one adapter enabled and the other disabled. If more than one adapter is enabled or disabled, you should display information about the adapters, and prompt the user for which one to enable or disable. You do not want the wired network adapter and the wireless network adapter enabled at the same time.
- This scenario is appropriate for a laptop, but not for a desktop computer. Therefore, your script should detect if the computer is a laptop or a desktop machine. If the computer is a desktop, the script should display a message that it only runs on laptop computers.
- The script should run without prompting if the default condition of one enabled network adapter and one disabled network adapter is met.
2012 Scripting Games links
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at email@example.com, or post your questions on the Official Scripting Guys Forum. Good luck as you compete in this year’s Scripting Games. We wish you well.
Ed Wilson, Microsoft Scripting Guy