Maybe you'd like to give some feedback to the users of your script while it processes a long-running task. One of the easiest (and most annoying) types of feedback is to play some "elevator music". Here's how:
function Start-ElevatorMusic { $wavfile = "c:\path_to_some_wav_file\jeopardy.wav" Add-Type -AssemblyName Microsoft.VisualBasic $script:player = New-Object Microsoft.VisualBasic.Devices.Audio $script:player.Play($wavfile, 'BackgroundLoop') }
Once you call Start-ElevatorMusic, PowerShell starts to play the music file you specify forever. Now, your script can do whatever it needs to do. Once done, call Stop-ElevatorMusic to stop the music again.
function Stop-ElevatorMusic { $script:player.Stop() }
Isn't that fun?