Skip to content

How to use PowerShell Get-Command

Jordan Hammond fun headshot
Jordan Hammond|January 22, 2020
Generic blog header
Generic blog header
Sections
    No Data

    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!

    PowerShell Get Command 1

    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.

    Get Command 2

    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. 

    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!

    Get Command 3

    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… (See Get-Command for more info)

    Loading...

    Jordan Hammond fun headshot
    Jordan Hammond

    Jordan had spent his life wondering why tasks he didn’t like to do had no options to complete themselves. Eventually he had to make that happen on his own. It turned out that he enjoyed making tasks complete themselves, and PDQ thought that is something he should talk about on the internet.

    Related articles