Why does this PowerShell script hang?
- by jshin47
Today I had to use Start-Sleep many times so I thought I would create a shortcut function for it, sleep($time). However, whenever I entered the function it never exits! It must be an issue with either the data type for the argument for Start-Sleep or the way I am declaring the function. Instead of posting the whole script, I've posted this useless one that would make a familiar beep pattern if it worked:
function beep {
Write-Host `a
}
function sleep {
param([int]$time)
Start-Sleep -m $time
}
beep
sleep(300)
beep
sleep(200)
beep
sleep(50)
beep
sleep(300)
beep
sleep(450)
beep
sleep(200)
beep