Welcome back to this series on Microsoft Windows PowerShell mastery, utilizing real-world examples you can make use of today.

Next, you may need to tell PowerShell to respect TLS 1.2, as it does not by default, even though ALOT of websites use this as their SSL (Secure Sockets Layer) method. Your PC or server may already have TLS 1.2 enabled, so proceed on this item as needed. If you get an error that says an SSL connection could not be established, this is likely what is required to move past it.
Note: This change applies only to the current session, and must be reset each time – so include it in your script if you do not have TLS 1.2 enabled across the board.

Now we will download data from the URL provided for storage in the $z variable. If you have been following my tutorials on PowerShell lately, this part should feel quite familiar to you.

Now things get more complex. We need to do a few things here.
- We will assign the number One to a variable called $n.
- We will construct a string appending the value of $n as a numerical prefix to the given element title.
- We will loop through the elements within the $z variable to produce a list of titles, displayed in Yellow.
- We will incrementally increase the value of $n by One.

Some looping occurs now. Do not move past this point in the script until you understand it.

Great. We have a formatted list of titles now. But what about the content? Surely we do not want to stop at just titles.
Let’s go deeper.

Above we have added the “Read-Host” command which allows us to capture user input within the PowerShell console for further use. In this case we will take a number and then go back to our data for next steps.

Don’t be discouraged. If statements are a key way to manage the flow of your automation scripting based on the data returned and/or the input given. In this case we will proceed only if a numerical value above Zero was provided.
In the above segment, we are taking the $zchoice value and are reducing it by One. We do this because, to your computer, the numbering for entries starts at Zero, as opposed to One. If we applied the exact number shown and given by the user, we would not receive the correct article info.
Note that we do not close the If statement block out here (with a “}”) because we need a bit more logic baked within it to get the results we want.
From there we have told PowerShell what data to show and in what colors. Here we have cast the title in Yellow and the Description in Green.

Next we ask the user if they want to read more, and then we refuse input which is incorrect for our purposes here (Y vs N, indicating “Yes” vs. “No”.).
If the user submits any value not matching “Y”, “y”, “N”, or “n”, we decline to proceed – programatically.

Proceeding from the above, we then process the “Y” responses which fall within spec (“Y” or “y”).
Note: In a production script I would suggest also accepting all case-versions of the word “Yes”, which would include “yes”, “Yes”, “YEs”, “YES”, and others. – but this is just a tutorial.
Above we:
- launched an instance of Internet Explorer
- Navigated to the link which corresponds to the article number chosen
- Made IE visible to the end-user

In the above script segment we wrap up our automation script by giving a fond farewell to the user who decides NOT to visit the link associated with their chosen article.
Now, we simply close our our script block with a “}” and the script should run as described.

And entering a “Y” in the above Read-host prompt initiates my visit to this page, in Internet Explorer.

Imagine what else you could automate using this method….
Now, go forth and use your newfound Automation Powers for Good instead of Evil.
Note: If you found this article, and/or others of mine, valuable – donate here: https://cash.app/$Zeaun
