- SmartDeploy: Rethinking software deployment to remote workers in times of a pandemic - Thu, Jul 30 2020
- Outlook attachments now blocked in Office 365 - Tue, Nov 19 2019
- PolicyPak MDM Edition: Group Policy and more for BYOD - Tue, Oct 29 2019
Out of the box, help in PowerShell is incomplete. To see what I mean, type Get-Help Get-Command on a new machine. In the remarks section of the output, you should see the following error message about partial help files.
To ensure that the PowerShell help files are updatable, Microsoft only ships the bare minimum that is needed for help. Although it might seem odd, let’s explore Update-Help and Save-Help first. Then we will jump back to Get-Help (and cover a really great hotkey trick).
The first command that you should run in PowerShell is Update-Help. This cmdlet ensures that you have the most complete and up to date PowerShell help files on your computer. When you run Update-Help, PowerShell will enumerate every module stored in the PSModulePath environment variable.
PSModulePath environment variable
Each module contains a Help URL which PowerShell uses to locate the online help files. These files are compared against the local help files; any newer files are downloaded to replace the local outdated files.
Things are a little more complicated than they seem because most modules are stored in C:\Windows\System32\WindowsPowerShell\v1.0. If you try to run Update-Help, you will likely receive an error stating that Update-Help was unable to update certain modules.
By default, PowerShell runs as a standard user. The Update-Help cmdlet doesn’t have the ability to replace the protected files listed in the error above. The trick is to run PowerShell as an administrator. The easiest way to do this is through the WINX menu on Windows 8.1.
As a best practice, regularly run Update-Help. You can schedule a regular update by creating a scheduled task. You can also use Group Policy Preferences to deploy a scheduled task to any IT computer. If you have remote or disconnected computers, downloading help files from Microsoft might be impractical. This takes us to the Save-Help cmdlet.
When using the Update-Help cmdlet, you might have noticed the –sourcepath parameter. This parameter allows you to specify an internal network share as your help file location. Save-Help allows you to download the help files to a network location. This command has changed a bit with PowerShell 4.
The syntax is simple and the only requirement is that the network folder must exist beforehand. On a network share (such as on a script repository), create a new folder named HelpFiles. In PowerShell, run Save-Help –DestinationPath “\\SERVER\SHARE\HelpFiles\”. When the command completes, your folder will be populated with each help .CAB file. You can even automate this task by setting a scheduled task to download updated files on a regular basis.
Help .CAB files
Administrators in your organization can now run Update-Help –SourcePath “\\SERVER\SHARE\HelpFiles\”. You can make this step even easier by prepopulating the –SourcePath value with Group Policy!
In the Group Policy Management Console, edit a GPO and navigate to Computer Configuration/Policies/Administrative Templates/Windows Components/Windows PowerShell. Enable Set the default source path for Update-Help and plug in your HelpFiles UNC. After a GPUpdate, machines will use your network location to download updated help files!
No matter your PowerShell experience, Get-Help will be one of your most used cmdlets. The cmdlet Get-Help can be accessed in a multitude of ways. The first is by running Get-Help CMDLET. For example, Get-Help Get-Command.
Personally, I learn the best when I can see actual examples of command being used. Get-Help can show you this by using the parameter –examples. To show you what I mean, Get-Help Get-Command –Examples would display 14 detailed samples!
To retrieve the entire help for a specific command, you can run Get-Help CommandName –full. If you are using PowerShell ISE, you are probably familiar with the Command pane. After searching for a cmdlet in this pane, you can press the blue question mark button to pull the full cmdlet help file in an external window.
Help in PowerShell ISE
But my favorite (and easiest) way to get help is found in the PowerShell ISE scripting pane. After typing a cmdlet, press F1 on your keyboard to launch a windowed help file.
Help with F1
As long as your typing cursor is touching the command, F1 will launch a help window for that command.
Help in PowerShell is extremely robust! Update-Help ensures that you have the latest documentation. Save-Help allows you to centralize help files for quicker access. The many iterations of Get-Help allow you to learn a PowerShell cmdlet in the most comfortable method for you.