10 Funny PowerShell Scripts

CompcIT
2 min readApr 5, 2024

--

Here are the 10 best funny scripts for PowerShell. You can try these scripts with your friends. But remember, don’t hurt anyone. These scripts could prove very hurtful for your friends or loved ones. So, be sure that when you are trying these scripts with your friends, your friends should have a good sense of humor.

Mouse Cursor Explosion

This script will make it difficult to control by moving the mouse cursor to random locations on the screen every 100 milliseconds.

while ($true) {
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point -ArgumentList (Get-Random -Minimum 0 -Maximum 1920), (Get-Random -Minimum 0 -Maximum 1080)
Start-Sleep -Milliseconds 100
}

Desktop Icons Shuffles

Every ten seconds, this script will swap the desktop icons at random.

$shell = New-Object -ComObject Shell.Application
$folder = $shell.Namespace('C:\Path\To\Desktop')
$items = $folder.Items()
$count = $items.Count

while ($true) {
$item1 = Get-Random -Minimum 0 -Maximum $count
$item2 = Get-Random -Minimum 0 -Maximum $count
$folder.MoveHere($items.Item($item1))
$folder.MoveHere($items.Item($item2))
Start-Sleep -Seconds 10
}

Caps Lock Madness

Every half a second, this script will turn the Caps Lock key on and off.

Add-Type -AssemblyName System.Windows.Forms
while ($true) {
[System.Windows.Forms.SendKeys]::SendWait('{CAPSLOCK}')
Start-Sleep -Milliseconds 500
}

Volume Control Hijack

Every five seconds, this script will change the system volume at random.

while ($true) {
$vol = Get-Random -Minimum 0 -Maximum 100
Set-Volume -Volume $vol
Start-Sleep -Seconds 5
}

Infinite MessageBox Loop

Until it is closed, this script will keep displaying a message box saying, “Your computer has been hacked!”

while ($true) {
[System.Windows.Forms.MessageBox]::Show("Your computer has been hacked!")
}

Fake Blue Screen of Death

Every ten seconds, this script will show a fictitious “Blue Screen of Death” message box.

while ($true) {
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.MessageBox]::Show("Blue Screen of Death!")
Start-Sleep -Seconds 10
}

Random Desktop Wallpaper Change

Every 30 seconds, this script will switch the desktop wallpaper to a randomly selected picture from a given folder.

$path = "C:\Path\To\Wallpapers"
$files = Get-ChildItem $path -Filter *.jpg

while ($true) {
$wallpaper = $files | Get-Random
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop\' -Name Wallpaper -Value $wallpaper.FullName
rundll32.exe user32.dll, UpdatePerUserSystemParameters
Start-Sleep -Seconds 30
}

Endless CD Drive Opening

Every second, this script will eject every CD drive in the system.

while ($true) {
(New-Object -com Shell.Application).Namespace(17).Items() | ForEach {
$_.InvokeVerb('Eject')
}
Start-Sleep -Seconds 1
}

Desktop Flip

Every ten seconds, this script will change the desktop wallpaper.

while ($true) {
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop\' -Name WallpaperStyle -Value 1
rundll32.exe user32.dll, UpdatePerUserSystemParameters
Start-Sleep -Seconds 10
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop\' -Name WallpaperStyle -Value 0
rundll32.exe user32.dll, UpdatePerUserSystemParameters
Start-Sleep -Seconds 10
}

Random Keyboard Typing

Every 50–200 milliseconds, this script will simulate random key presses.

$keys = [char[]]('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()')

while ($true) {
$key = Get-Random -InputObject $keys
[System.Windows.Forms.SendKeys]::SendWait($key)
Start-Sleep -Milliseconds (Get-Random -Minimum 50 -Maximum 200)
}

Recall to use these scripts sensibly and with your friends’ permission. Jokes ought to be lighthearted and enjoyable! For more information, visit our website.

--

--

CompcIT

Do Not Let The Technology Evolve Behind Your Back.