When was Update-Help last run?

I’m just curious f there’s a way to tell when the last time the Update-Help cmdlet was run. If I knew this, I could put in my profile something like…
if ($update.date -lt 1 week) {update-help}

I could do it every wednesday or something, but i open/close PS many times daily.

I could drop a breadcrumb, such as a text file exists and was last modified on this date… and that would do it, but i’d like to know if PS has this feature already for me to use.

Thanks :slight_smile:

If you don’t use -Force, there’s already an “only once per 24 hours” behavior, so running it multiple times per day without -Force isn’t so bad. Otherwise, I’m not sure where the countdown clock is kept. You could certainly just store your own value somewhere, though, and trigger off that.

Oh cool, that 24-hour thing is the missing piece… thanks again, Don!

You can schedule it like below so that it updates every week on a specified day & time.

Register-ScheduledJob -Name UpdateHelpJob -Credential Domain01\User01 -ScriptBlock {Update-Help} -Trigger (New-JobTrigger -Daysofweek Thursday -At “5 PM”)

Hey Don,
I noticed today that the Update-Help ran multiple times, each time I opened ISE or the console. I closed it and reopened it and sure enough, the update help runs again, even though it had just run.

Is the 24-hour limit a feature in a newer version? Is there some global variable I can check for the run behavior?

Here’s what I have in my profile, that should only run on Wednesdays but not more than once a day (per your advice).

# Update-Help will only run once per 24h, unless the -Force flag is used. 
if ((get-date).DayOfWeek -eq 'Wednesday') {Update-Help}

[EDIT]:
Hi Nagendra, I just tried your method and it was missing the “-Weekly” mandatory parameter. Thanks, it looks OK when run with that. How would I ensure the help is up to date? I guess that brings it around full circle huh?

I put this in my $profile

$isupdated = (Get-Item 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\en-US\').LastWriteTime.Day
$today = (Get-Date).Date.Day
    If (($isupdated) -eq ($today))
        {
        Write-Host "Powershell help files were updated today."
        }
    else
    {
        Write-Host "Updating Powershell help files.."
        Update-Help
    }