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 the While statement

In VBScript, you had the While...Wend loop. An example of using the While...Wend loop is the WhileReadLineWend.vbs script that follows. The first thing you do in the script is create an instance of the FileSystemObject and store it in the objFSO variable. You then use the OpenTextFile method to open a test file, and store that object in the objFile variable. You then use the While...Not ...Wend construction to read one line at a time from the text stream and display it on the screen. You continue to do this until you are at the end of the text stream object. A While...Wend loop continues to operate as long as a condition is evaluated as true. In this example, as long as you are not at the end of the stream, you will ...

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