Uncategorized

Basic PowerShell commands explained

I have created two heavily commented PowerShell scripts that explain the usage of basic PowerShell commands. This may come in handy when you are handed over an existing PowerShell script but you yourself have no experience with the PowerShell language. This is meant as a fast explainer of existing code.

Copy the two powershell scripts from the GitHub link below, place them together in any directory.

In both files the code is explained through comments. The easiest way to get started is to open the PowerShell Integrated Scripting Environment or ISE. I usually tap the windows key and then type ISE into the prompt. Inside the ISE go to File>>Open and open the file Introduction.ps1.

Run the script by pressing F5 or the play butting. Code snippets can be executed by selecting them and pressing F8. Be aware that by using F8, the concept of $PSScriptRoot won’t work anymore as you are not running the file, but only a few lines from the file.

pieterdelange/LearnPowerShell: This repository hosts PowerShell code snippets and example scripts for explaining PowerShell. (github.com)

PowerShell has some very nice concepts which you will miss out on if you only look at these commands. I highly recommend finding learning resources if you are looking for how to build your own PowerShell scripts from scratch.