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:
Okay. That was too many. Let’s use wildcards to narrow it down to just commands for services:
Now we are getting somewhere! You can see the
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.
Get-Help we can learn how to use
What about a simple example of stopping a service?
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
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
Based on these methods I can also call
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.