Enabling PowerShell Hardcore Mode

Haha, run into a tweet from "nohandle" earlier today that made me laugh out loud. Enabling PowerShell Hardcore Mode 🙂

Enabling PowerShell Hardcore Mode

Hardcode Mode basically means that you configure PowerShell to shutdown the computer if you type in a command that does not exist.

Note: do NOT do this on any production machine, or at least don't yell at me if the machine turns off 🙂

$ExecutionContext.InvokeCommand.CommandNotFoundAction = { Stop-Computer -Force }

image

As long as you don't mistype any command, all is well. But one single typo, and this happens:

image

Happy Deployment, Johan

About the author

Johan Arwidmark

0 0 votes
Article Rating
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
PowershellGirl
PowershellGirl
7 years ago

This is awesome. I think I'll try replacing restart-computer with exit, in other words I have to start all over again if I fuck up, lol.


>