There are many wonderful PowerShell modules available and published at PowerShell Gallery, but as time passes many modules will receive new versions with bug fixes, features and help updates. The function Invoke-ModuleUpdate aims to hopefully solve the problem with new available versions by querying the PSRepository for each module to find if any new version is available, and later update that module if the parameter -Update was specified.
Heres an example when running Invoke-ModuleUpdate just to query the repository for a new version.
If you want to update modules specify the switch parameter -Update
The default behavior of Invoke-ModuleUpdate without any parameters specified is to query the repository for a new version for all installed modules.
1 |
Invoke-ModuleUpdate |
If you wan’t you can run the function on a weekly basis simply by adding a Schedued Job.
1 2 3 4 5 6 |
$TaskAction = New-ScheduledTaskAction -Execute "$PSHOME\powershell.exe" -Argument "-ExecutionPolicy Bypass -NoProfile -Command `"& {Omnicit\Invoke-ModuleUpdate -Update}`"" $TaskTrigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Friday -At 08:00 $TaskPrincipal = New-ScheduledTaskPrincipal -RunLevel Highest -LogonType S4U -Id 'Author' -ProcessTokenSidType Default -UserId ('{0}\{1}' -f $env:USERDOMAIN, $env:USERNAME) $TaskSettings = New-ScheduledTaskSettingsSet -WakeToRun -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1) -Compatibility Win8 $ScheduledTask = New-ScheduledTask -Action $TaskAction -Principal $TaskPrincipal -Trigger $TaskTrigger -Settings $TaskSettings -Description 'Use Omnicit\Invoke-ModuleUpdate to update modules' Register-ScheduledTask -InputObject $ScheduledTask -TaskName Invoke-ModuleUpdate |
Installation
The Invoke-ModuleUpdate is a function available in the Omnicit PowerShell Toolbox.
If you have the PowerShellGet module installed you can enter the following command:
1 |
Install-Module -Name Omnicit -Scope CurrentUser |
Check out the GitHub page for more information and available cmdlets.