3 Cmdlets to Discover PowerShell

Reading time ~2 minutes

Learning PowerShell can be really easy! With a few handy cmdlets you can teach yourself enough PowerShell to get started. In this post I will teach you 3 essential cmdlets for learning PowerShell and discovering more.

I often find myself doing simple operations with services. Getting lists of services, starting them, stopping them, etc. For my examples I will show off the Service related cmdlets and objects. These are just examples and I would encourage you to explore commands you use regularly or are interested in.

If this post is too long for you, try reading the TL;DR version on TechNet by Microsoft.

Get-Command - Find Commands!

There are thousands of different built-in commands for PowerShell. Finding what you need is easy with Get-Command (TechNet). You can search for commands by name, verb, noun or parameter to find the exact cmdlet you need.

Let’s find all the commands:

Output from 'Get-Command'

Okay. That was too many. Let’s use wildcards to narrow it down to just commands for services:

Get-Command *Service
Output from 'Get-Command *Service'

Now we are getting somewhere! You can see the Get-Service, Start-Service and Stop-Service cmdlets. Ok, now how do we use them?

Get-Help - How do I use a command?

Learning how to use any command is easy with Get-Help (TechNet). The built-in documentation shows all the parameters, examples and any additional notes.

Using Get-Help we can learn how to use Get-Service:

Get-Help Get-Service
Output from 'Get-Help Get-Service'

What about a simple example of stopping a service?

Get-Help Stop-Service -Examples
Output from 'Get-Help Stop-Service -Examples'

The PowerShell help also has meta topics like about_operators. This can be a great way to learn intricate details about PowerShell without ever leaving your prompt. In this example I show how to review the built-in keywords using Get-Help.

Get-Help about_Language_Keywords
Output from 'Get-Help about_Language_Keywords'

Get-Member - What can an object do?

Many commands, like Get-Service return objects you can interact with. Get-Member (TechNet) tells you exactly what methods and properties any object has available.

In this example I show members returned on the objects from Get-Service:

$service = Get-Service PlugPlay
$service | Get-Member
Output equivalent to the output of 'Get-Service | Get-Member'

Based on these methods I can also call $service.Stop() or $service.Start() instead of Stop-Service and Start-Service to stop/start services. Cool.

Get-PowerShell - Go Have Fun!

I hope these basic cmdlets are helpful to you. I use them all the time to find my way around and learn new commands/objects. These cmdlets were invaluable to me when I first learned PowerShell.

Want more articles for learning PowerShell? Try PowerShell.org or the links from these other blog posts:

UPDATE: I have been listening to the PowerScripting Podcast learning neat things coming up in Windows/PowerShell. In almost every podcast they recommend PowerShell in a Month of Lunches by Don Jone’s. I have not watched any of these videos yet, but from the titles they look good.

Enjoy and happy discovering PowerShell.

I would like to thank my lovely wife Angela for helping review this post. She was gracious enough to take time out of her vacation to find where the apostrophes and dashes should go. Thanks dear, I love you.

I would also like to thank my son, Jude, for not smashing the keyboard.

The Worst Week of My Life

In January I had the worst week of my life. My wife and I joked we wanted to start 2016 in February. Within a single week I lost my job a...… Continue reading