Your colleague went to lunch again without properly locking his computer? Then this is your chance to run this code on his PowerShell:
$powershell = [PowerShell]::Create() $code = { while ($true) { Start-Sleep -Milliseconds 3000 [Console]::Beep(400, 500) } } $null = $powershell.AddScript($code) $handle = $powershell.BeginInvoke()
It starts a background thread and beeps every three seconds. Fortunately, beeping stops when you close PowerShell. It’s a simple example illustrating how you can run arbitrary PowerShell code in a new background thread.