- Let's run a command that will result in an error. For now, let us not focus on the syntax of the command; our only goal for now is to generate an error. At the first line of the script window, type in the following:
PS> Get-ChildItem /home/ram/random-directoryPS> Write-Host "Hello world!"
- Run the two-liner script using the F5 key:
PowerShell is prompt to show an error. It also displays the Hello world! string.
- Let's set the error action preference, using the variable, ErrorActionPreference. We know there's such a variable ...