Click an Ad

If you find this blog helpful, please support me by clicking an ad!

Wednesday, March 5, 2014

Creating a Shortcut to Run a Powershell Script

So I've got a bunch of useful script scattered throughout this blog, and sometimes I want to fire one off quickly. You know, without opening a Powershell prompt and typing a full pathname in.

BRING FORTH THE SHORTCUT!!!

Right-click on your desktop and make a new shortcut. For the location of the item, type in:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -File <PathToScript>

Remember to enclose <PathToScript> in quotes if it has space in it. My advice to you would be to use CamelCase at all times so you don't have to worry about that, though.

And voila! You have a shortcut that you can click on to run a script!

If you need to see the output before the PowerShell window goes away, try adding a dummy read-host command to the end of the script you're calling, like so:

$Pause = Read-Host "Press Enter to Continue"

This way, when the script gets finished, it will hang there at a "Press Enter to Continue" prompt.

No comments:

Post a Comment