Keep Powershell help up to date in the background
Powershell

Keep Powershell help up to date in the background

When you run Powershell in a new computer, and try to use the Get-Help cmdlet, Powershell will ask you if you want to update help first, If you choose not to, the help you will get will be very limited.

The help system in Powershell is great. I think its the first thing everyone should master before they jump into Powershell. By default, Powershell ships without the help files, so first you have to update the Powershell help database to unlock its power. Over the time, you will collect more modules and updates, so keeping it up to date is a challenge.

Powershell help no database

Running Get-Help without help files

When you run Powershell in a new computer, and try to use the Get-Help cmdlet, Powershell will ask you if you want to update help first, If you choose not to, the help you will get will be very limited.

To update the help files manually,  just type Update-Help and let Powershell do it thing. The only downside of this command is that you have to wait until it finishes updating all the modules, and the more you have, the longer it will take. Doing it once is OK, but keeping it up to date is time-consuming, and I personally always forget…

Updating Powershell help in the background

We can run the update-help cmdlet and wait, but who loves to wait? Powershell can run jobs in the background, and we can use it to update the help database. To do so, we will use the Start-Job cmdlet:

PS C:\> Start-Job -Name 'Update Help' -ScriptBlock {update-help -force}
 
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
1 Update Help BackgroundJob Running True localhost update-help -force

Now Powershell will update the help files and we can continue to work without waiting for the update to finish. If we want to check if the job is complete, we can use the Get-Job cmdlet:

PS C:\> Get-Job
 
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
1 Update Help BackgroundJob Completed True localhost update-help -force

Automating the process

If you don’t want to deal with the update process, we can add the job to our profile. every time we start a new Powershell session, it will check for updates and preform update if needed. And the best part? it running in the background!

Now go update you help files 😉


Share Tweet Send
0 Comments
Loading...