Windows Powershell Tutorials – Discovering Commands and Using Help

When you start learning powershell you wont be knowing all the commands. So the help system will let you discover the commands and gives you a short note about what a particular command does. By using help you can avoid lots ans lots of errors and you can save time in the learning process.

The first thing you have to do is update the help system. You can update the help system using the following command.

The above command will update all the help files associated with powershell.

Getting Started:
If you want to know what are the options available for a particular command Update-Help will do the work. Let say , you want to know about update-help command. Issue the following command in the powershell window to get a detailed information about the Update-Help command.

If you want to see the results in a separate window, where you can search for a particular string, use the following command.

Discovering Commands:
As you start learning , you wouldnt be aware of most of the commands. So lets say , you want to know the command which shows you all the details about ipadress. Powershell has a great way to discover command using help. Poweshell supports wildcard search. The following command will search for the commands which has the ipaddress string attached to it.

The above command will list out all the commands which includes ipaddress. From that you can get the command which shows you all the ipaddress details. In this case it is Get-NetIpAddress

Using Help:
Now you know how to discover a command and the next thing you have to learn is that what and all parameters and values you can pass to the particular command. You can find that using the help command. The following command will show you the details and syntax of the Get-Service command.

The syntax section in the help will show you how to use the command. In the help section of Get-Service command , syntax looks like the following image.

If you look at the image above, there are three ways you can use the Get-Service command. The strings which start with are parameters and <string[]> means values which you pass to the command. The two square brackets which are jammed one against each other means that you can pass multiple values with the command. The commands within square brackets are not mandatory, which means you can run the Get-Service all by itself and it return all the available services.

-Name is a positioned parameter in Get-Service command, which mean if you pass a value with Get-Service method with or without the -Name Parameter, it will give the same output. Its because , powershell automatically adds the positioned parameter to the value. Int this case -Name parameter is positioned first. For example, the following two commands will give the same output.


Changing the error color:
When ever you get an error , it will be shown in red color. There is a simple command which changes the error color if you don’t like red. The following command will change the error color from red to green.

Related

This tutorial will guide you through the steps for deploying a plain spring web application to a tomcat server. If…

Read more

Q: When I try to use images using "insert into post" option, WordPress is giving a blank page and the image is not…

Read more

Converting a .pem to .ppk format is a matter of one line code. First, you need to have puttygen installed on your…

Read more
About

The Best Tutorials & Tips to Speedup Your DevOps Workflow.

Created by Bibin Wilson.