PowerShell for Windows Admins

Jan 15 2013   3:38PM GMT

Updating Help on PowerShell v3



Posted by: Richard Siddaway
Tags:
PowerShell 3

One of the new features in PowerShell v3 is the capability to update the help files. In fact you have to do this because PowerShell v3 doesn’t ship with any help files. Since Windows 8 RTM’d there have been a succession of new help files released.

I discovered one of my netbooks didn’t have the latest version of the help files installed. So I needed to update them. This got me thinking that it would be better if the machine did this for me.

I could think of two easy ways to do this – a scheduled job or a scheduled task. I chose the scheduled task because the ScheduledTasks module is available on the version of PowerShell v3 for Windows 7 and other legacy versions of Windows. The PSScheduledJob module is only available on Windows 8/2012 as it’s based on WMI classes not present on older versions of Windows.

$actionscript = '-NonInteractive -WindowStyle Normal -NoLogo -NoProfile -NoExit -Command "& {Update-Help -UICulture en-US -Force}"'            
$pstart =  "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"            
#$days = "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"             
$days = 'Wednesday'            
            
Get-ScheduledTask -TaskName UpdatePSHelp | Unregister-ScheduledTask -Confirm:$false            
            
$act = New-ScheduledTaskAction -Execute $pstart -Argument $actionscript            
$trig = New-ScheduledTaskTrigger -Weekly -WeeksInterval 4 -At 19:00 -DaysOfWeek $days            
Register-ScheduledTask -TaskName UpdatePSHelp -Action $act -Trigger $trig -RunLevel Highest

Start by creating the command strings to start PowerShell and the arguments you pass to it.  I left it as a visible PowerShell window that stays opn so I can see the results. The PowerShell command

Update-Help -UICulture en-US –Force

performs the actual update.  You will need to change the culture to match yours if you aren’t using English.  You can find it by using

Get-UICulture

I’m only going to run this on Wednesdays .

Any old copies of the task are cleaned out and new task actions (to execute PowerShell) and trigger to define when it runs are created. The last line registers the task.

You can view the task

Get-ScheduledTask -TaskName UpdatePSHelp

or start the task manually

Start-ScheduledTask -TaskName UpdatePSHelp

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: