Powershell FOR Loop Statement Example

Source: Internet
Author: User

Example One
for ($counter = 1;$counter -le 10;$counter ++){    "loop number $counter"    }    <#    loop number 1loop number 2loop number 3loop number 4loop number 5loop number 6loop number 7loop number 8loop number 9loop number 10#>
Example Two
for ($i = 1; $i -lt 99; $i++){ for ($counter = 0;$counter -lt 5;$counter++){if($counter -eq 2){continue}Write-Host "processing item $i,$counter"}}
Results
processing item 94,0processing item 94,1processing item 94,3processing item 94,4processing item 95,0processing item 95,1processing item 95,3processing item 95,4processing item 96,0processing item 96,1processing item 96,3processing item 96,4processing item 97,0processing item 97,1processing item 97,3processing item 97,4processing item 98,0processing item 98,1processing item 98,3

Please follow the public number below to get more it information:

Powershell FOR Loop Statement Example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.