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 comment