Powershell is a very powerful language yet a lot of developers get frustrated by some of it’s little quibbles.
Learning a few little details make working with powershell much easier.
Items to consider are:
- Continue On Error
- Strict Options
- Comparison Operators
- Type System
- The Pipeline
Powershell commands are always formed Verb-Noun although they can have a more familiar alias.
The beauty of Powershell is how configurable and reflective it is.
If you don’t like the default behaviour then it can easily be adjusted.
For example to find the automatic variables you can use the simple command:
dir variable::*
This lists the variables defined in global scope, including the automatic variables.
Details of these can be found using:
get-help about_auto | more
For example you can change the continue on error by setting $ErrorActionPreference
If you don’t think that PowerShell is strict enough on checking the parameters and types you can use:
Set-StrictMode -Version Latest
This is the Implicit None from Fortran (or VB’s OPTION STRICT).
It means that you get warned if you try to use an uninitialised variable.
PowerShell uses the prefix [Type] to define a type.
So:
$a = [int]16
is valid.