Skip to content

Instantly share code, notes, and snippets.

@nichollsc81
Created July 6, 2021 09:42
Show Gist options
  • Save nichollsc81/45721c2def2c0fa63d00dc1cfea76214 to your computer and use it in GitHub Desktop.
Save nichollsc81/45721c2def2c0fa63d00dc1cfea76214 to your computer and use it in GitHub Desktop.
Updates all global user modules from admin scope
function Update-AllUserModules
{
[cmdletbinding(SupportsShouldProcess = $True)]
param()
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, 'Update all user modules'))
{
(Get-InstalledModule).Name | ForEach-Object {
Write-Verbose "Updating module: $_"
try
{
Update-Module $_ -Scope AllUsers -Force -Verbose:$VerbosePreference
}
catch
{
$_
[environment]::Exit(1)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment