http://powershell.org/wp/2015/11/07/november-2015-scripting-games-puzzle
Our Puzzle
Scripting challenge: Understanding and cleaning up someone else’s code
Below is an actual script that was in production use at a large enterprise client. The script worked as desired, but as you can see, it could benefit from some clean up. There is some old code in there that may have served a function at one time, but no longer does. The original author and several editors donít seem to have understood PowerShell very well, and it is far more complex than it needs to be.
Your challenge is to replace everything after the Param statement with a single line of code (no semicolons), while retaining all functionality.
We are not looking for the shortest line. The whole point is to make the code more readable. Don’t replace unnecessarily complex with unnecessarily cryptic.
As in real life, you should also add internal documentation in the form of any concise comments about the script or your new code which may be of value to the next person troubleshooting or updating the script.