Friday, September 10, 2010

Simple timed while loop

A simple way of executing a while loop over a certain amount of time:



$now = Get-Date
$later = $now.AddSeconds(15)

while($now.second -lt $later.second){

cls
$now = Get-Date
$now.second
sleep 1

}

2 comments:

  1. Hey, how are you going about pasting code into your blog posts? I'm interested in getting the line numbers!

    Cheers,
    Trevor

    ReplyDelete
  2. http://alexgorbatchev.com/SyntaxHighlighter/

    ReplyDelete