Create infinite loop in Powershell

I was looking into taking a script block and running this in a infinite loop in Windows Powershell in order to perform testing of a particular action over a sustained period of time.

I was able to do this while using the calling the While expression with a true value, which will perform an endless loop during the powershell session.

While($true)
    { 
    $i++
    <action to invoke>
    Write-Host "Action has run $i times" 
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s