O'Reilly logo

PowerShell and WMI by Foreword by Ed Wilson, Richard Siddaway

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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";
Expression={$_.ConvertToDateTime($_.LastBootUpTime)}}

A.3. Flow syntax

The if and switch statements are used to control flow:

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required