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 :)


