Identifying changing values
Let’s think about things we might want to change in this code. We want it to get weather information from the web and write it to a HTML document. This means it’s unlikely that we want to change the Invoke-RestMethod
, Convertto-Html
, and Out-File
cmdlets. Think about what values might change before we move on.
Ready? Good.
These are some things that we might want to be able to change the values of when we run the script:
- We might want to change the city.
- We might want to change where we save the HTML output.
- We might want to change the API key.
- We might not want to hardcode the API key in the script at all.
We can pass values for these things when we call the script by making them parameters within the script. The next section will be all about parameterizing our script.