PDQ.com mobilePDQ.com desktop
Support

PowerShell Get-Command

Jordan Hammond
·

Ever been in the middle of writing a script and you forget a command you have used dozens of times? I do it all the time, I may be the world's foremost authority on forgetting stuff that I know at the exact moment that I need it. In almost all scenarios I am left with no option but to weep in the corner for a while. Not with PowerShell, they have taken steps to protect myself from….myself.

Let’s say that for work related reasons I absolutely NEED candy crush. Some jerk sysadmin has taken it upon himself to regulate fun…….I mean work. I am not sure what the command is, but I know that this is an app, let’s test it!

Add-AppPackage looks promising! It also says that it is an alias, but the source is appx. Let’s take a look at the appx module and see what commands we can come up with.

Now we have a list of all the appx that we need!

I am going to have to come clean now, this may be hard to believe, but the example I used was not real life experience. In the name of full disclosure I will tell you I knew that command when I started. I apologize for my deceit. 

I had this moment of honesty because when looking for your command you will not always have a portion of the command ready to go, and typing in several searches trying different things will work. Searching through your console as you type a few searches can bury what you are looking for. Luckily for you I have something that will help your searching, and make all of this a little easier. 

Enter Out-Gridview.

Get-Command | Out-GridView

Running this command will put all of your commands in a window. You can try what you are thinking in the built in filter, test several searches quickly, and have much better luck at finding what you are looking for. Look how happy this window is!

Wow, it turns out the truth will set you free, I feel great right now. Time for me to get out of here. If only I could remember the command I need to publish this blog…

Don't miss the next post!

Software Rollback

How to rollback or uninstall software patches due to an unexpected network vulnerability.