PowerShell Back-to-School Scripting Challenge

For many people, it is back-to-school time. This time of years always makes The Chairman nostalgic, so he has commissioned a new set of PowerShell scripting challenges. These tasks are aimed at beginner level PowerShell scripters, with a few bonuses targeted toward intermediate users. Although everyone is welcome and encouraged to try their hand.

The Challenges

You need to create simple PowerShell functions to meet the following goals. Each task should result in a separate function.

  • Given 2 lengths of a right triangle, calculate the missing length. You will need to let the user specify which sides (traditionally A,B and C) of the triangle they are specifying.
  • Calculate the area of a circle with a given diameter.
  • Calculate the volume of a sphere with a given diameter.
  • Calculate the volume of a cylinder from a given diameter and height.
  • Calculate the factorial of an integer.

Intermediate Additions

For those of you with a bit more PowerShell experience, your functions should include parameter validation and error handling. Your function should have an option to write a rich object to the pipeline. For example, the first challenge might have you write an object with properties of A, B, and C. Finally, you should be able to create a simple module with a manifest.

As with all challenges, please submit links to your work in the comments and not the code itself.

And it is OK to ask your kids for help. 😉


15 Replies to “PowerShell Back-to-School Scripting Challenge”

  1. thedavecarroll

    I have been working on this solution since the challenge was presented, but wasn’t able to put a considerable chunk of effort into it at any given time.

    A few of the learning points were definitely new to me, such as ValidateRangeKind and the [double]::NaN. I knew of the [math] class, but I haven’t used it that often.

    Overall, this was another fun challenge.

    Here is my solution: https://bit.ly/2ZEhLKM

Leave a Reply

Your email address will not be published. Required fields are marked *