Today was PowerShell day for me at the PASS Summit. After just 3 hours of sleep last night, I did not expect too much (from myself). However, the coffee was good and the realisation of a new skill was enough to keep me going.
It’s fair to say that, although the presentation was a little disjointed, I have seen the PowerShell ‘light’ and what it is capable of. I intend to follow up this precon with a hefting helping of new blogs to read and scripts to write.
The following are some of the notes from the precon today.
What is PowerShell?
According to Wikipedia, PowerShell is a task automation framework, that consists of a command-line shell and an associated scripting language. With PowerShell, administrators can perform administrative tasks on both local and remote machines.
- Cmdlets
- Are specialised commands in the PowerShell environment that implement specific functions.
- Use a verb-noun naming pattern. i.e.
- Get-Command
- Get-Children
- Sets of commandlets can be combined into scripts and executables.
- Pipeline
- PowerShell implements a pipeline, which enables the output of one cmdlet to be ‘piped’ as an input to another; this is done using the ‘|’ character.
Variables in PowerShell
Variables in PowerShell are declared (using ‘$’) and set in-line. There is no need to declare them up front, or set their data/object type. The variables will take on the appropriate data/object type for the result(s) that are returned. I don’t know about you, but I think that is all kinds of awesome.
PowerShell Profiles
These help to load up certain modules/snapins when you load up PowerShell. This means you can port your profiles to any environment and be able to load into a familiar setup.
Comparison operators
| Operator | Description |
| -eq | Equal to |
| -ieq | Equal to (case-insensitive) |
| -ceq | Equal to (case-sensitive) |
| -ge | Greater than or Equal to |
| -gt | Greater than |
| -le | Less than or Equal to |
| -lt | Less than |
Logical Operators
| Operator | Description |
| -and | And |
| -ne | Not Equal to |
| -not | Not |
| ! | Not |
| -or | OR |
more operator notes over at http://ss64.com/ps/syntax-compare.html
PowerShell Resources – great for those just starting out in PowerShell
- PowerShell Day 0
- PowerShell Day 1
- PowerShell Day 2
- PowerShell Day 3
- PowerShell Day 4
- PowerShell Day 5
- PowerShell Day 6
- http://www.scriptingguys.com
- http://www.poshcode.org
- http://blogs.technet.com/b/heyscriptingguy/
- http://www.beefycode.com/
- 10 Fundamental Concepts for PowerShell Scripting
- Finding Free Space per data file with PowerShell
- Restore and relocate database files using PowerShell