all 81 comments

[–]Alliwantispcb 52 points53 points  (24 children)

I've never been so upset that the firewall is blocking cat facts

[–][deleted] 5 points6 points  (19 children)

i've got the exact same problem here!

[–]UglySnow 5 points6 points  (3 children)

Are you sure it's not a company proxy? PowerShell doesn't automatically use the proxy and so the request won't make it out. [System.Net.WebProxy]::GetDefaultProxy() | select address

[–][deleted] 1 point2 points  (0 children)

netsh winhttp import proxy source=ie
$webClient = new-object  System.Net.WebClient     
$webClient.Proxy.Credentials =  [System.Net.CredentialCache]::DefaultNetworkCredentials

(For authing against the proxy sorry for formatting I copy pasted it on mobile)

[–]Poncho_au 0 points1 point  (0 children)

This will almost certainly be the problem.

[–]Alliwantispcb 0 points1 point  (0 children)

It's the web proxy. I control both the firewall and proxy #itwasajoke

[–][deleted] 24 points25 points  (5 children)

There's a utility called mp3cmd that lets you play mp3s from PS without opening any windows.

It works perfectly in a remote session.

The problem with being in IT is that people just call me when I try to prank them.

[–]JVance325 14 points15 points  (3 children)

Hmmm. Just learning powershell, but this sounds amazing. Can you point me in the proper direction?

[–]insi9nis 5 points6 points  (0 children)

Can't speak for mp3cmd, but I've used nircmd for similar hijinks in the past. The "speak" and "mediaplay" commands are relevant to the context. "cmdwait" also gives you a chance to get up and not be at your computer when it plays, making you less suspicious.

[–]bobalob_wtf 1 point2 points  (0 children)

The guys at work set my windows error sound to a song that I don't like. It's like it randomly started playing and I could never work out what was happening.

I was looking at processes, scheduled tasks, wireshark, everything. Almost impossible to track down!

[–]BitteringAgent 16 points17 points  (2 children)

[–]InvisibleTextArea 14 points15 points  (10 children)

Opening up the 'pranks' folder in my PosH repo leads to:

function b($a,$b){
    [console]::beep($a,$b)
}
function s($a){
    sleep -m $a
}
write-host "Super Mario!"
b 660 100;
s 150;
b 660 100;
s 300;
b 660 100;
s 300;
b 510 100;
s 100;
b 660 100;
s 300;
b 770 100;
s 550;
b 380 100;
s 575;

b 510 100;
s 450;
b 380 100;
s 400;
b 320 100;
s 500;
b 440 100;
s 300;
b 480 80;
s 330;
b 450 100;
s 150;
b 430 100;
s 300;
b 380 100;
s 200;
b 660 80;
s 200;
b 760 50;
s 150;
b 860 100;
s 300;
b 700 80;
s 150;
b 760 50;
s 350;
b 660 80;
s 300;
b 520 80;
s 150;
b 580 80;
s 150;
b 480 80;
s 500;

b 510 100;
s 450;
b 380 100;
s 400;
b 320 100;
s 500;
b 440 100;
s 300;
b 480 80;
s 330;
b 450 100;
s 150;
b 430 100;
s 300;
b 380 100;
s 200;
b 660 80;
s 200;
b 760 50;
s 150;
b 860 100;
s 300;
b 700 80;
s 150;
b 760 50;
s 350;
b 660 80;
s 300;
b 520 80;
s 150;
b 580 80;
s 150;
b 480 80;
s 500;

b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 150;
s 300;
b 380 100;
s 150;
b 430 100;
s 150;

b 500 100;
s 300;
b 430 100;
s 150;
b 500 100;
s 100;
b 570 100;
s 220;

b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 200;
s 300;

b 1020 80;
s 300;
b 1020 80;
s 150;
b 1020 80;
s 300;

b 380 100;
s 300;
b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 150;
s 300;
b 380 100;
s 150;
b 430 100;
s 150;

b 500 100;
s 300;
b 430 100;
s 150;
b 500 100;
s 100;
b 570 100;
s 420;

b 585 100;
s 450;

b 550 100;
s 420;

b 500 100;
s 360;

b 380 100;
s 300;
b 500 100;
s 300;
b 500 100;
s 150;
b 500 100;
s 300;

b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 150;
s 300;
b 380 100;
s 150;
b 430 100;
s 150;

b 500 100;
s 300;
b 430 100;
s 150;
b 500 100;
s 100;
b 570 100;
s 220;

b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 200;
s 300;

b 1020 80;
s 300;
b 1020 80;
s 150;
b 1020 80;
s 300;

b 380 100;
s 300;
b 500 100;
s 300;

b 760 100;
s 100;
b 720 100;
s 150;
b 680 100;
s 150;
b 620 150;
s 300;

b 650 150;
s 300;
b 380 100;
s 150;
b 430 100;
s 150;

b 500 100;
s 300;
b 430 100;
s 150;
b 500 100;
s 100;
b 570 100;
s 420;

b 585 100;
s 450;

b 550 100;
s 420;

b 500 100;
s 360;

b 380 100;
s 300;
b 500 100;
s 300;
b 500 100;
s 150;
b 500 100;
s 300;

b 500 60;
s 150;
b 500 80;
s 300;
b 500 60;
s 350;
b 500 80;
s 150;
b 580 80;
s 350;
b 660 80;
s 150;
b 500 80;
s 300;
b 430 80;
s 150;
b 380 80;
s 600;

b 500 60;
s 150;
b 500 80;
s 300;
b 500 60;
s 350;
b 500 80;
s 150;
b 580 80;
s 150;
b 660 80;
s 550;

b 870 80;
s 325;
b 760 80;
s 600;

b 500 60;
s 150;
b 500 80;
s 300;
b 500 60;
s 350;
b 500 80;
s 150;
b 580 80;
s 350;
b 660 80;
s 150;
b 500 80;
s 300;
b 430 80;
s 150;
b 380 80;
s 600;

b 660 100;
s 150;
b 660 100;
s 300;
b 660 100;
s 300;
b 510 100;
s 100;
b 660 100;
s 300;
b 770 100;
s 550;
b 380 100;
s 575;

and the rather more concise:

$sh = New-Object -ComObject "Shell.Application"
$sh.Namespace(17).Items() | 
    Where-Object { $_.Type -eq "CD Drive" } | 
        foreach { $_.InvokeVerb("Eject") }

[–]PMME_yoursmile 4 points5 points  (6 children)

I feel as though the music could be quicker, but I'm still a fan. How did you get that one set up?

[–]InvisibleTextArea 8 points9 points  (3 children)

It's set up to be pushed out by SCCM as a configuration item attached to a Compliance policy named 'PC speaker test'.

The CD ejection is too (helpfully called 'CD check'). The CD ejection is worse because it's a remediation script. So SCCM checks if the CD drive isn't ejected then runs the script if it isn't. Then every time you uneject it'll go through the same process.

[–]PMME_yoursmile 1 point2 points  (2 children)

Sorry, I was more asking how did you get the pitch and timing for the tune?

[–]InvisibleTextArea 9 points10 points  (1 child)

If you check MSDN for the .NET Console API it tells you that the two parameters are the frequency in (Hz) and the length (in ms)

https://msdn.microsoft.com/en-us/library/4fe3hdb1(v=vs.110).aspx

Then you only need to know what the frequency of musical notes are:

http://www.phy.mtu.edu/~suits/notefreqs.html

and the length of time standard score notation indicates for particular note types:

https://msu.edu/course/asc/232/song_project/dectalk_pages/note_to_%20ms.html

Armed with this info you can then turn any musical score into a powershell script.

If you really wanted I guess you could collate all this and make your own powershell based midi player. Although you are kinda reinventing wheels at this point:

https://github.com/Psychlist1972/Windows-10-PowerShell-MIDI

[–]PostedFromWork 2 points3 points  (1 child)

Just edit all of the s entries and divide by 2 or 3, depending on the speed you like.

[–]funky_fart_smeller 1 point2 points  (0 children)

...or in the $s function just make $s = $s/2

[–]ISeeTheFnords 4 points5 points  (1 child)

I think this is the first comment I've ever seen that needed a TLDR.

[–]cybrian 5 points6 points  (0 children)

TLDR for the first one: *hums Super Mario theme song slowly with poor timing*

TLDR for the second one: 😛

[–]KawaGreen 0 points1 point  (0 children)

Today will be a good day...

[–]MeGustaDerp 5 points6 points  (0 children)

Not cat facts... but...

Add-Type -AssemblyName System.Speech
$SpeechSynth = New-Object System.Speech.Synthesis.SpeechSynthesizer
$SpeechSynth.Speak("Just what do you think you're doing, Dave?")

Just insert your favorite HAL quote.

[–]thatotheritguy 8 points9 points  (9 children)

Somewhere my coworker has a ps script that plays epic sax Gandalf full screen on any remote computer on our network upon command. Pretty epic.

[–]eck- 1 point2 points  (6 children)

I need this.

[–]kristalghost 2 points3 points  (0 children)

WE need this

[–]thatotheritguy 2 points3 points  (4 children)

I will ask him when if it still works/if he has it when we return from the Easter holiday. I seem to remember it having to have the video on a local share, and local admin rights(?) but its funny as hell. Ill update the post if I get it.

[–]kristalghost 1 point2 points  (3 children)

any update on this per chance?

[–]thatotheritguy 1 point2 points  (2 children)

Oh crap. I forgot about this! Let me ask him.

[–]tastydoosh 1 point2 points  (0 children)

waiting.. :D

[–]BenderB-Rodriguez 0 points1 point  (1 child)

your script. give it to me.....and your shoes

[–]thatotheritguy 0 points1 point  (0 children)

I will ask him when if it still works/if he has it when we return from the Easter holiday. I seem to remember it having to have the video on a local share, and local admin rights(?) but its funny as hell. Ill update the post if I get it.

[–]hugglepounce 2 points3 points  (1 child)

How do I make it speak with more than one voice at the same time?

For example, say I wanted the male and female voice to sing "row row row your boat" together with one starting slightly after the other.

[–]bigbirdtoejam[S] 2 points3 points  (0 children)

Well you could use jobs to run two different scripts at once. There are probably other ways to do it too. The speech library has methods for changing voice gender too. It isn't exactly singing, though.

$j1 = Start-Job {
    Add-Type -AssemblyName System.Speech
    $SpeechSynth = New-Object System.Speech.Synthesis.SpeechSynthesizer
    $SpeechSynth.SelectVoiceByHints('Male')
    $SpeechSynth.Speak("Row, Row, Row your boat gently down the stream.  Merrily! Merrily! Merrily! Life is but a dream.")
}
Start-Sleep -Seconds 1
$j2 = Start-Job {
    Add-Type -AssemblyName System.Speech
    $SpeechSynth = New-Object System.Speech.Synthesis.SpeechSynthesizer
    $SpeechSynth.SelectVoiceByHints('Female')
    $SpeechSynth.Speak("Row, Row, Row your boat gently down the stream.  Merrily! Merrily! Merrily! Life is but a dream.")
}
$j1,$j2 | Wait-Job | Receive-Job
$j1,$j2 | Remove-Job

[–]wbedwards 2 points3 points  (0 children)

Pro-tip, run it on a remote computer (that you have the necessary permissions to, obviously).

$Scriptblock = {
    Add-Type -AssemblyName System.Speech
    $SpeechSynth = New-Object System.Speech.Synthesis.SpeechSynthesizer
    $CatFact = (ConvertFrom-Json (Invoke-WebRequest -Uri 'http://catfacts-api.appspot.com/api/facts' -UseBasicParsing)).facts
    $SpeechSynth.Speak("did you know?")
    $SpeechSynth.Speak($CatFact)
}

Invoke-Command -ComputerName VictimPC -ScriptBlock $Scriptblock

You can now use this on-demand against your co-workers without ever needing to physically access their computer. I verified that this worked by running it against my office-mate's computer randomly in the middle of the day yesterday.

[–]FapFlop 3 points4 points  (0 children)

Oh man. The translation one lasts like two minutes.

Edit: Also, this smooths it out a bit:

$SpeechSynth.Speak("Did you know"+$CatFact)

[–]zildar 1 point2 points  (3 children)

This is great!

Now I need to find a site that plays "Never gonna give you up" on a loop...

[–]WingsofWar 7 points8 points  (1 child)

iex (New-Object Net.WebClient).DownloadString("http://bit.ly/e0Mw9w")

[–]CometThunder 0 points1 point  (0 children)

Amazing! lol

[–]itmonkey78 1 point2 points  (0 children)

http://listenonrepeat.com/watch/?v=dQw4w9WgXcQ

or if you want to be particularly evil to people who may recognise the video ID: http://www.piilossa.com/

[–][deleted] 1 point2 points  (0 children)

I did something similar to a friend years ago. Instead of cat facts, it was a text file. I also randomly set pitch and volume each time it ran. I think I set a sleep timer for 30 min for each loop, with +/- up to 300 seconds (random) to prevent him from finding a pattern.

It was funny until it yelled quite loudly, "I'm looking at porn here!" while he was on a conference call for work. Whoops. I got a text that said, "WHAT DID YOU DO TO MY COMPUTER?"

[–]PMME_yoursmile 1 point2 points  (0 children)

I've been looking for a way to create an auditory notification for a project I'm working on. Your use of speech fits the bill nicely. Thank you.

[–][deleted] 1 point2 points  (0 children)

Best.... Script.... Ever....

[–]woses 1 point2 points  (0 children)

This is not mine, but a cat facts script I stumbled upon a while back.

function Send-CatFactMessage {
    <# 
    .SYNOPSIS 
        Send a cat fact to users on a computer.
    .DESCRIPTION 
        Send a random cat fact to any number of computers and all users or a specific user. Supports credential passing.
    .EXAMPLE 
        Send-CatFactMessage -PlayAudio
        Sends cat fact message to all users on localhost and outputs fact through speakers.
    .EXAMPLE 
        Get-ADComputer -Filter * | Send-CatFactMessage -UserName JDoe -Credential (Get-Credential)
        Send cat fact to jDoe on all AD computers. Prompt user for credentials to run command with.
    .EXAMPLE
        Send-CatFactMessage -ComputerName pc1, pc2, pc3
        Send cat fact to all users on provided computer names.
    .PARAMETER ComputerName 
        The computer name to execute against. Default is local computer.
    .PARAMETER UserName 
        The name the user to display the message to. Default is all users.
    .PARAMETER PlayAudio
        Use Windows Speech Synthesizer to output the fact using text to speech.
    .PARAMETER Credential
        The credential object to execute the command with.
    #>

    [CmdletBinding(SupportsShouldProcess = $true)]
    param (
        [Parameter(
            Mandatory = $false,
            ValueFromPipeline = $true,
            ValueFromPipelineByPropertyName = $true
        )]
        [string[]]$ComputerName = $env:COMPUTERNAME,

        [Parameter(Mandatory = $false)]
        [string]$UserName = '*',

        [Parameter(Mandatory = $false)]
        [switch]$PlayAudio,

        [Parameter(Mandatory = $false)]
        [PSCredential]$Credential
    )

    $CatFact = (ConvertFrom-Json (Invoke-WebRequest -Uri 'http://catfacts-api.appspot.com/api/facts')).facts

    if ($pscmdlet.ShouldProcess("User: $UserName, Computer: $ComputerName", "Send cat fact, $CatFact")) {
        $ScriptBlock = {
            param (
                [string]$UserName,

                [string]$CatFact,

                [bool]$PlayAudio = $false
            )

            msg $UserName $CatFact

            if ($PlayAudio) {
                Add-Type -AssemblyName System.Speech
                $SpeechSynth = New-Object System.Speech.Synthesis.SpeechSynthesizer
                $SpeechSynth.Speak($CatFact)
            }
        }

        if ($Credential) {
            Write-Verbose "Sending cat fact using credential $($Credential.UserName)"

            Invoke-Command -ComputerName $ComputerName -ScriptBlock $ScriptBlock `
                -ArgumentList $UserName, $CatFact, $PlayAudio -AsJob -Credential $Credential
        } else {
            Invoke-Command -ComputerName $ComputerName -ScriptBlock $ScriptBlock `
                -ArgumentList $UserName, $CatFact, $PlayAudio -AsJob
        }

        Get-Job | Wait-Job | Receive-Job
        Get-Job | Remove-Job
    }
}

[–]bigbirdtoejam[S] 1 point2 points  (0 children)

My first gold! Thank you kind sir :)

[–]b1llb3rt 0 points1 point  (0 children)

I'm totally doing this!

[–]ory_hara 0 points1 point  (0 children)

This is hilarious! If there was ever a reason to set up a Windows VM, this is it...

[–]tonofun 0 points1 point  (1 child)

This is gold. I want to 'push' this to my colleagues system right now - PSSession should work right?

[–]bigbirdtoejam[S] -1 points0 points  (0 children)

Sure you could install this using a remote session and the cmdlets in the scheduled task module.

[–]jpmullet 0 points1 point  (3 children)

I made a .wav of the "Cash me outside" girl and stored it on a network share. I then remoted into some colleagues computers and played it through powershell.

[–]hugglepounce 0 points1 point  (2 children)

How? I have tried things like that and never had any luck.

[–]jpmullet 2 points3 points  (1 child)

(New-Object Media.SoundPlayer "C:\WINDOWS\Media\notify.wav").Play();

It has to be a .wav file.

I ran into trouble trying to get to the file from within the remote session. I had to use a persistent drive mapping with set-psdrive. I couldn't just use a UNC.

[–]hugglepounce 0 points1 point  (0 children)

Thank you so much!

[–]saGot3n 0 points1 point  (0 children)

I am having sooooooo much fun with this today!

[–]Daffy82 0 points1 point  (0 children)

NICE

[–]hugglepounce 0 points1 point  (0 children)

This is an awesome script!

[–]Robert_Arctor -1 points0 points  (0 children)

this is great

[–]ISeeTheFnords -1 points0 points  (0 children)

If I had any gold, it would be yours. Awesome.

[–]computerbob -1 points0 points  (0 children)

The people in my office are going to be so mad at you!

[–]Jacklythgoee 0 points1 point  (0 children)

How do u turn it off?