Gary's $this and that about PowerShell

I am a Microsoft Senior Premier Field Engineer based out of Atlanta, GA. My focus is Powershell. This blog is mainly to share interesting Powershell script samples.

Fun Script to Never Run While in a Hospital

Fun Script to Never Run While in a Hospital

  • Comments 1
  • Likes

In class today a student asked about having a little fun and simulating a flat line heartbeat monitor.  He was sparked on to this by my demoing the PowerShell alert (beep): “`a”

$frequency = 2000            
            
$signature = @"
    [DllImport("kernel32.dll")] public static extern bool Beep(int freq,int duration);
"@            
            
Add-Type -MemberDefinition $signature -Name "Beeper" -Namespace Win32Functions -PassThru            
            
For ($i = 500 ; $i -le 1500 ; $i += 100)            
{            
    [Win32Functions.Beeper]::Beep($frequency,300)            
    Start-Sleep -Milliseconds $i            
}            
            
[Win32Functions.Beeper]::Beep($frequency,3000)
Comments
Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment