O'Reilly logo

Windows PowerShell™ 3.0 Step by Step by Ed Wilson

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

Chapter 19 quick reference

To

Do this

Handle a potential error arising from a missing value of a computername parameter

Use the param statement and assign a default value of $env:computername to the computername parameter.

Make a parameter mandatory

Use the [Parameter(Mandatory=$true)] parameter attribute.

Cause the Test-Connection cmdlet to return a Boolean value

Use the -quiet switched parameter.

Ensure a remote computer is up prior to making a remote connection

Use the Test-Connection cmdlet.

Ensure that only valid data types are entered

Write a function to test the data prior to executing the remaining portion of the script.

Ensure that code will always run, regardless of whether an error is raised

Place the code in the Finally block of ...

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