Created
July 6, 2021 09:42
-
-
Save nichollsc81/45721c2def2c0fa63d00dc1cfea76214 to your computer and use it in GitHub Desktop.
Updates all global user modules from admin scope
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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