The Chairman realizes that many IT Pros who take on his challenges are experienced and advanced PowerShell users. But everyone was a beginner once. Everyone had that first challenge of writing a PowerShell function. Today’s challenge is for those of you in the early stages of learning PowerShell. Now, it is time for you to begin scripting. For this beginner challenge, the Chairman would like you to write 2 very simple functions.
You should write a function to convert a Fahrenheit temperate to Celsius and a second function to do the opposite. The functions can be very simple with a single parameter for the value to convert. You don’t need to worry about passing values from the pipeline, error handling or anything advanced. The function can simply write the converted value to the pipeline as a result. If you are feeling a bit more confident, have your function write an object to the pipeline with the original and converted values.
Even though this is a basic and beginner challenge, you should still follow PowerShell scripting best practices such as using a proper verb-noun naming convention. If you feel a bit more skilled, feel free to include error handling, parameter validation and pipeline input.
To help you along, you can use these formulas to convert temperatures. To convert from Celsius to Fahrenheit: (C*1.8)+32. To convert from Fahrenheit to Celsius is a matter of reversing the process: (F-32)/1.8. As points of reference, freezing is 32F and 0C. Boiling is 212F and 100C.
As always, please don’t submit any code solutions as comments. But you are encouraged to share links to your work.