Powershell

Table of Contents

Getting Help

From the previous exercise we now have our shell up and running with the latest version of Powershell 5. Before we start running commands and stary our journey you will have to update the current help system on your shell.

To update your current shell help system, run the command below with PowerShell as administrator.

Update-Help


You will be prompted to download help files from the internet. By clicking Yes the shell will look into Microsoft's Docs website and pull the repository of information regarding all the current commands and their usage. It wont make a difference whether you update PowerShell help in the PowerShell console or in PowerShell ISE. The help files are the same and are stored in C:\Windows\System32\WindowsPowerShell\v1.0\en-US.



You may receive an error that some files may not have downloaded. As long as their is no firewall blocking your Internet traffic on your network and that you can browse to this URL https://docs.microsoft.com/en-gb/powershell/module/microsoft.powershell.core/about/about_updatable_help?view=powershell-6&viewFallbackFrom=powershell-Microsoft.PowerShell.Core then you will be able to download the update help files to your computer.

Here's what Update-Help does by default:
As you can see in the screen-shot above received when running PowerShell the help file for a module is missing its link. Regardless this can be ignored as the module is not important and the remainder of the file exists.

To have a real life look on where these help commands are downloaded from you may visit the below URL to have a visual look of what the host will download and see to your computers location where the PowerShell host shell is currently installed. PowerShell Help

Now that the new updated help files are downloaded on the system we can test it by running the get-help command against the most common used Windows administration command get-ChildItem. We will need to use the -name parameter to specify the value of the command to run the help method function against.

Get-Help -Name Get-ChildItem




If you look at the output of the column names are universal to all help files. The Get-Help command outputs the online content of a commands help file into an viewable host output. It makes it easier to understand various examples on how to use a command without having to painstakingly open up a web browser and google search Microsoft documentation website for the command Get-ChildItem.

Putting this output into practice we can see that Get-ChildItem Syntax column shows 3 unique ways of constructing a paramtised command query. This means if you want to use the parameters in the order of any 1 of the 3 Syntax methods you will be limited to use only the rest of the parameter commands. This is because of the way the method is constructed from a function.

Remember all PowerShell commands are are a wrapper over .Net framework commands in an easily viewable two (2) word Bakcus-Naur format. This means the first word is a Verb e.g. "Get" and the second word is a Noun e.g. "ChildItem". This is as PowerShell was developed as an automation language. That means a programming language that is used to make tasks easier. Instead of typing out a long Visual Basic (Pre legacy programming language used before PowerShell) script to get the contents (files) of a directory. Powershell neatly wraps this Visual Basic code in a named function (Method) called Get-ChildItem.

Looking at the description Get-Childitem accepts parameters for inputting data to run against the shell and output the contents of a directory. Microsoft powershell help files are downloaded into the local windows directory "C:\Windows\System32\WindowsPowerShell\v1.0\en-US".

Through the second Syntax method we can see that Get-ChildItem has a "-path" parameter which accepts a String data type. This means if we define a text string encapsualted by double quotations. "Example of a string". We can use the string within the -path parameter with Get-ChildItem to get the directory contents of a path specified.

Therefore If you want to yourself see the location of the installed help files you can then run the Get-ChildItem command against the directory help files are installed to see that files with "help" text in their name exist.

Get-ChildItem -Path "C:\Windows\System32\WindowsPowerShell\v1.0\en-US"




We can see from the output that indeed the Get-ChildItem command worked in finding the help files we downloaded earlier and returned an Object output.

Visit next page to learn about - Commands