August 13, 2020
WSL and powershell
Powershell is, among other things, a windows scripting language.
As you might expect, there are a lot of terrible tutorials out there. Some are too infested with ads to even read.
Others seem to "start in the middle" assuming you already know about powershell, but want to learn more
(which is hardly a tutorial, eh?). These notes are hardly expected to be a tutorial, they are just my notes
as I try to learn.
Powershell ISE is an IDE for writing powershell scripts, but as soon as I learn about it, I find out that it is deprecated.
Microsoft wants to move you to using visual studio for this.
Powershell scripts end in ".ps1" -- yep, that is a numero uno, not a letter "l".
Powershell is .NET based, object oriented, and you deal with "cmdlets" where a "cmdlet" is verb-noun,
such as:
Get-Help
Comment lines begin with #, block comments are sandwiched between <# and #>
echo
"echo" is an alias for the cmdlet "Write-Output" and seems to do what you might expect.
Powershell does variable interpolation into strings, so apparently you can do the
following to display the value of a variable.
echo "Count: $counter"
Semicolons
These can be used between two statements placed on a single line.
Using them elsewhere seems to be an optional style issue.
C# programmers are used to putting semicolons at the end of lines and continue
this practice with powershell.
They are allowed and harmless, but it does not seem that they are required.
There may be more to this. I certainly see people slapping semicolons on the
ends of most lines. As near as I can tell this is just habit and/or style.
Have any comments? Questions?
Drop me a line!
Tom's electronics pages / [email protected]