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

Using PromptForChoice to limit selections: Step-by-step exercises

This exercise will explore the use of PromptForChoice to limit selections in a script. Following this exercise, you will explore using Try...Catch...Finally to detect and to catch errors.

Exploring the PromptForChoice construction

  1. Open the Windows PowerShell ISE.

  2. Create a new script called PromptForChoiceExercise.ps1.

  3. Create a variable to be used for the caption. Name the variable caption and assign a string value of This is the caption to the variable. The code to do this appears here:

    $caption = "This is the caption"
  4. Create another variable to be used for the message. Name the variable message and assign a string value of This is the message to the variable. The code to do ...

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