If we want to learn how to drive a car, we need someone who can teach us to learn driving a car. While if we want to use a software, we need to know how the software works and the first thing we start looking for is the HELP menu inside the software. Similarly, when we start working with PowerShell, there is a HELP system already provided to us by the PowerShell Engine which we can look upto anytime using some commands to learn or get help on the various commands available to us.
So the question is how do we reach out to PowerShell Help System !?
The answer is very simple: Get-Help. Yes, this is the very first command you can ask the PowerShell Engine to get help for any commands available.But before we start taking help from the PowerShell Help System, it would be wise to keep the Help System updated so that we get the most recent version of the information.
Now How do we update the PowerShell Help System?
Again the answer is quite simple. Run the Update-Help command in the PowerShell Host, say for now the PowerShell Console. But there’s a catch to this. Update-Help will only work if your machine is connected to the internet and you have started the host as Run as Administrator.
So few points to remember here while using Update-Help command is:
- Make sure the system is connected to the internet.
- Start the PowerShell Host as Admin.
- Execute Update-Help
If you do not start the PowerShell Host as Admin, you may see Access is denied error during the update.
What if there is no internet connection? Can not we update the help system at this point? If yes, how?
Answer is yes, we can definitely update the help-system. Suppose that your and your friend need to complete a homework and your friend has already got the answer bank. So what you can do is you can take printouts of the answer bank and keep it one copy for yourself so that you can look up to it anytime.Same is the case for PowerShell Help System. If one machines already has updated Help contents, then you can use the Save-Help command to make a copy of all the updates help contents. Then you can use this copy as a source to update the Help system of your machine where there is no internet connection.
Save-Help command looks like this:
Save-Help -DestinationPath “C:\Help” -Force
where C:\Help is the folder where all the XML files are saved, -Force can be used if you want to overwrite the folder if already exists.
The folder contents look like this:
Now that we have all the help files downloaded, how do we update our machine using them.Command looks like this:
Update-Help -SourcePath “C:\Help”
So these are the ways how we can update our PowerShell Help System.
Now How do we use Help?
Suppose you want to find out the list of services running in your machine but you are not sure which command is available in the PowerShell to get the list of the services. This is where you need Help.See the below example to get a list of commands available to related to services:
Here you can see the commands and you can start playing with those.If you are not sure how each command works, Help is there for you again. For example if you want to find out about Get-Service, try something like “help Get-Service” and PowerShell Help will show you everything you need including syntax, description, parameters and examples.
In this manner, you can try out other keywords which can be noun or verb and then deep dive into specific commands.Few other ways of using Help are with the additional parameters like:
- To see the examples, type: “get-help Get-Service -examples”.
- For more information, type: “get-help Get-Service -detailed”.
- For technical information, type: “get-help Get-Service -full”.
- For online help, type: “get-help Get-Service -online”
Keep scripting guys… Stay tuned! 🙂