
上QQ阅读APP看书,第一时间看更新
How to do it…
To update the Help files for the locally installed PowerShell modules, follow these steps:
- Type exit to exit PowerShell. This is so that you can relaunch PowerShell with elevated privileges. This is required for some of the modules, based on the permissions used to install them.
- Enter sudo pwsh (or sudo pwsh-preview) to launch PowerShell as a superuser.
- At the PS> prompt, run Update-Help.
- Wait for the update progress bar to appear. The bar will fill as the Help files download onto your computer:

- Use exit to exit PowerShell as a superuser, and launch PowerShell as a regular user.
We can now proceed and fetch Help information for other cmdlets.
- At the command prompt, enter the following command:
PS> Get-Help Write-Host
You will get an output similar to the following:
- Next, gather different levels of Help information by using the following commands:
PS> Get-Help Write-Host -Full
PS> Get-Help Write-Host -Examples
PS> Get-Help Write-Host -Online
- Pass a different cmdlet as a parameter to Get-Help. Note the two groups of parameters:
PS> Get-Help Get-Command
- Compare the outputs of the different commands you ran.
- Now, look for Help information for the specific parameter of Write-Host (the second command in the following code is for reference; this states what the first command means to PowerShell):
PS> get-help write-host -par foregroundcolor
PS> # Verbose version: Get-Help -Name Write-Host -Parameter ForegroundColor
Now let's look for a certain keyword within the Help information:
- Convert the output of Get-Help Get-Command into text, one string at a time, rather than putting in the entirety of the Help information as a single string:
PS> get-help get-command | out-string -s
PS> # Verbose version: Get-Help Get-Command | Out-String -Stream
- Pipe this to the Select-String cmdlet to perform a grep-like operation:
PS> get-help get-command | out-string -s | select-string 'wildcard'
PS> # Verbose version: Get-Help -Name Get-Command | Out-String -Stream | Select-String -Pattern 'wildcard'
- This gives you an output of a line that contains wildcard:
