In VBScript, a For...Next loop was somewhat easy to create. An example of a simple For...Next loop is shown in DemoForLoop.vbs. You use the For keyword, define a variable to keep track of the count, indicate how far you will go, define your action, and ensure that you specify the Next keyword. That is about all there is to it. The DemoForLoop.vbs is shown here:
For i = 1 To 5 WScript.Echo i Next
You can achieve the same thing in Windows PowerShell. The structure of the For loop in Windows PowerShell resembles the structure for VBScript. They both begin with the keyword For, they both initialize the variable, and they both specify how far the loop will progress. One thing that is ...