Skip to content

Instantly share code, notes, and snippets.

@clemmesserli
Created January 8, 2021 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clemmesserli/ae3c5424a6ec8740c5c61e5481082041 to your computer and use it in GitHub Desktop.
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
#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