PowerShell pranks?

Hi all

I'm trying to improve my powershell knowledge, so I'm fiddling with some pranks to use on my coworkers.

Examples are:

Moving their mouse cursor

Opening their cd drive

Text to speech through their speaker

Changing their wallpaper

and so on.

However I'm often running into issues with it working for myself, but not when used within Invoke-Command for remote desktops. Everything is enabled so that remoting should work. I can succesfully run:

Invoke-Command -ComputerName Desktop1234 -ScriptBlock{Get-Service}

Also I know that this works on my own computer:

$Message = "Would you like to play a game?"
$speaker = new-object -com SAPI.SpVoice
$speaker.Speak($message, 1)

But if I wrap it in

Invoke-Command -ComputerName Desktop1234 -ScriptBlock{

$Message = "Would you like to play a game?"
$speaker = new-object -com SAPI.SpVoice
$speaker.Speak($message, 1)

}

The command finishes without any errors, but no sound is played. Can anyone say why or how to make it work?

If I would like for the cursor to move to the corner of the screen every 5 seconds, I uset his code, which works on my own computer:

[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

do {[Windows.Forms.Cursor]::Position = "1,1";sleep 5}until (0)

But as soon as I wrap it, nothing happens:

Invoke-Command -ComputerName Desktop1234 -ScriptBlock{

[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

do {[Windows.Forms.Cursor]::Position = "1,1";sleep 5}until (0)

}


This goes on for just about every prank Ive come up with and I lack the understanding of why this doesnt work. Any help would be greatly appreciated :)

February 20th, 2014 10:10am

Sounds like a great way to get fired for wasting company time.

Best place to get started is here:

http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

Also, check out one of the plentiful PowerShell books on the market. Those will have some good examples to help you start writing scripts.

Free Windows Admin Tool Kit Click here and download it now
February 20th, 2014 10:21am

Sounds like a great way to get fired for wasting company time.


I've done exactly that...  When I was 20, I worked for a helpdesk where I used PSExec and Windows Media Player to play sound bytes out of other people's speakers.  Needless to say, I no longer work there.  :P
February 20th, 2014 10:28am

I've done exactly that...  When I was 20, I worked for a helpdesk where I used PSExec and Windows Media Player to play sound bytes out of other people's speakers.  Needless to say, I no longer work there.  :P
Ah, the fun old helpdesk days. Sometimes I look back fondly at all the time I had on my hands. I was big fan of shutdown /r /m \\otherHelpdeskPC /t 5 /c "HAHAHAHAHAHAHAHAHAHAHAHA take that".
Free Windows Admin Tool Kit Click here and download it now
February 20th, 2014 10:52am

SAPI requires a UI. It cannot be remoted with any technique.  If it could we would all be annoyed often.
February 20th, 2014 12:07pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics