Appendix A. PowerShell reference

This appendix supplies a number of templates, syntax formats, and other useful information that you can use when creating your PowerShell scripts.

A.1. Automatic variables

There are a large number of variables that PowerShell automatically creates. The list can be seen by using

Get-Help about_Automatic_Variables

Reviewing the contents of this help file is highly recommended.

A.2. Calculated fields

Use calculated fields to create new properties or to perform calculations:

Get-WmiObject -Class Win32_OperatingSystem |
select @{Name="BootTime";

A.3. Flow syntax

The if and switch statements are used to control flow:

if (<condition>){ .. statements .. } elseif ...

Get PowerShell and WMI now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.