Development Powershell Tutorials

Powershell – From deeply flawed to very powerful

“Powershell is such a great product because I’m a deeplyflawed human being.” – Jeffrey Snover, the creator of Powershell

Powershell is that friend that you can always rely on. When your memory fails you, Powershell is there to help!

In this post we’ll be talking about some of the features in Powershell that can assist you on your journey.
Lets begin with the Get-Help cmdlet.

Notice that I did not type -Name. That is because the Name parameter has a positional value of 0, which means that the first entered value will be inputted as Name.
More about this in a later post.

Type the cmdlet you want help with after Get-Help and you’ll see the above information.
At the bottom of the image you can see I’ve added -Detailed, and just like it sounds this gives more detailed information about the cmdlet.

The information is also available online, just search after the cmdlet name or what you want to do and you’ll find the Microsoft article.
For example here is the Get-Process article.

The syntax is explained here, I’ll paste the main part below:

<command-name> -<Required Parameter Name> <Required Parameter Value>
[-<Optional Parameter Name> <Optional Parameter Value>]
[-<Optional Switch Parameters>]
[-<Optional Parameter Name>] <Required Parameter Value>

Tab auto completion
Now this is a feature that you’ll be using all the time!
Start to write something, can be cmdlet names, parameters, variable names etc., and then hit tab and Powershell will try to guess what you wanted to type.
For example typing ‘get-pro’ and then hitting the ‘Tab key’ will give you ‘Get-Process’.
You can press tab several times, if what you typed could be resolved to several names than you’ll go through the list.
Pressing ‘Shift + Tab’ will go backwards in the list.

If a cmdlet can’t be auto completed, then either you’ve typed it incorrectly or the cmdlet isn’t loaded.
Now we haven’t started talking about modules and functions yet, but Powershell comes with some cmdlets builtin and then you can add more on top of those. We’ll look at that in a future post.

This is Microsoft’s context-aware code completion feature and it is very useful.
In Powershell ISE you have access to it automatically but if it doesn’t show up, which sometimes happens, you can get it to show by pressing ‘CTRL + Space’.
In the version of Powershell I’m running, Intellisense is also available in the shell (5.1.15063.1805), also by pressing ‘CTRL + Space’.

Intellisense in ISE with cmdlet names.
Intellisense in the shell for parameters.

Play around with these features and get comfortable with them and it will help you going forward!

As always, continue to learn and evolve your skills, see you in the next one!

Do you want to know more? Here is a list of tutorials to check next

Leave a Reply

Your email address will not be published. Required fields are marked *