Created
January 8, 2021 17:39
-
-
Save clemmesserli/ae3c5424a6ec8740c5c61e5481082041 to your computer and use it in GitHub Desktop.
This script can be used to forcibly remove the v3/v4 versions that typically ship with Windows and update to latest from PSGallery
This file contains 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
#Requires -RunAsAdministrator | |
$modules = Get-Module -Name Pester -ListAvailable | |
if ($null -ne $modules) { | |
$pesterPaths = (get-item $modules.modulebase).parent.Fullname | Sort-Object -Unique | |
foreach ($pesterPath in $pesterPaths) { | |
takeown /F $pesterPath /A /R | |
icacls $pesterPath /reset | |
# grant permissions to Administrators group, but use SID to do | |
# it because it is localized on non-us installations of Windows | |
icacls $pesterPath /grant "*S-1-5-32-544:F" /inheritance:d /T | |
Remove-Item -Path $pesterPath -Recurse -Force -Confirm:$false | |
} | |
} | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 | |
Install-Module -Name Pester -Scope AllUsers -Repository PSGallery -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment