0

#PSTip Keeping your help files up to date

Note: This tip requires PowerShell 3.0.

In PowerShell 3.0 you need to run the Update-Help cmdlet in order to stay up-to-date whenever new help content is available. The problem? You don’t know when new content is released (unless you visit the Updatable Help Status Table page periodically).

To ensure that your system has the latest help files, you can register a scheduled job that runs at specific intervals and runs the Update-Help cmdlet. In the following example, Update-Help will execute every day at 05:00 AM.

Register-ScheduledJob -Name UpdateHelp <code>
		      -ScheduledJobOption @{RunElevated=$true} </code>
		      -ScriptBlock {Update-Help -Force -Verbose} `
		      -Trigger @{At='5:00 AM';Frequency='Daily'}

You can find the newly created task in Task Scheduler UI, on the left pane, under the Task Scheduler Library\Microsoft\Windows\PowerShell\ScheduledJobs task folder.

Once the job has finished running you can get its result by using the job cmdlets:

Get-Job -Name UpdateHelp | Receive-Job -Keep

For more information about scheduled jobs, see about_Scheduled_Jobs.

Filed in: Columns, Tips and Tricks Tags: , , , , ,

Leave a Reply

Submit Comment

© 2016 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: