PowerTip: Generate Random Beeps with PowerShell

Doctor Scripto

Summary: Use Windows PowerShell to generate random beeps.

Hey, Scripting Guy! Question How can I generate random beeps by using Windows PowerShell?

Hey, Scripting Guy! Answer Create a range of numbers between 190 and 8500 that will determine the tone.
          Use the Get-Random cmdlet to choose a random number of tones. Pipe the results to the 
          ForEach-Object cmdlet, and call the Beep static method from the system.console class.
          The first number determines the tone, and the second number determines the length of the tone.
          Here is an example of this technique:

190..8500 | Get-Random -Count 35 | ForEach {[console]::Beep($_, 150)}


Discussion is closed.

Feedback usabilla icon