Skip to content

Instantly share code, notes, and snippets.

@nohwnd
Last active August 29, 2025 18:21
Show Gist options
  • Save nohwnd/5c07fe62c861ee563f69c9ee1f7c9688 to your computer and use it in GitHub Desktop.
Save nohwnd/5c07fe62c861ee563f69c9ee1f7c9688 to your computer and use it in GitHub Desktop.

Revisions

  1. nohwnd revised this gist Apr 11, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Uninstall-Pester.ps1
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ function Uninstall-Pester ([switch]$All) {

    #Requires -RunAsAdministrator
    $pesterPaths = foreach ($programFiles in ($env:ProgramFiles, ${env:ProgramFiles(x86)})) {
    $path = "$programFiles\$suffix\WindowsPowerShell\Modules\Pester"
    $path = "$programFiles\WindowsPowerShell\Modules\Pester"
    if ($null -ne $programFiles -and (Test-Path $path)) {
    if ($All) {
    Get-Item $path
  2. nohwnd revised this gist Apr 11, 2020. 2 changed files with 35 additions and 23 deletions.
    35 changes: 35 additions & 0 deletions Uninstall-Pester.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #Requires -RunAsAdministrator

    function Uninstall-Pester ([switch]$All) {
    if ([IntPtr]::Size * 8 -ne 64) { throw "Run this script from 64bit PowerShell." }

    #Requires -RunAsAdministrator
    $pesterPaths = foreach ($programFiles in ($env:ProgramFiles, ${env:ProgramFiles(x86)})) {
    $path = "$programFiles\$suffix\WindowsPowerShell\Modules\Pester"
    if ($null -ne $programFiles -and (Test-Path $path)) {
    if ($All) {
    Get-Item $path
    }
    else {
    Get-ChildItem "$path\3.*"
    }
    }
    }


    if (-not $pesterPaths) {
    "There are no Pester$(if (-not $all) {" 3"}) installations in Program Files and Program Files (x86) doing nothing."
    return
    }

    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
    }
    }

    Uninstall-Pester
    23 changes: 0 additions & 23 deletions Uninstall-Pester3.ps1
    Original file line number Diff line number Diff line change
    @@ -1,23 +0,0 @@
    #Requires -RunAsAdministrator
    $pesterPaths = foreach ($programFiles in ($env:ProgramFiles, ${env:ProgramFiles(x86)}))
    {
    $path = "$programFiles\$suffix\WindowsPowerShell\Modules\Pester"
    if ($null -ne $programFiles -and (Test-Path $path)) {
    Get-ChildItem "$path\3.*"
    }
    }


    if (-not $pesterPaths) {
    "There are no Pester 3 installations in Program Files and Program Files (x86) doing nothing."
    continue
    }

    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
    }
  3. nohwnd revised this gist Apr 11, 2020. 2 changed files with 23 additions and 14 deletions.
    14 changes: 0 additions & 14 deletions Uninstall-Pester.ps1
    Original file line number Diff line number Diff line change
    @@ -1,14 +0,0 @@
    #Requires -RunAsAdministrator
    $modulePath = "C:\Program Files\WindowsPowerShell\Modules\Pester"

    if (-not (Test-Path $modulePath)) {
    "There is no Pester folder in $modulePath, doing nothing."
    break
    }

    takeown /F $modulePath /A /R
    icacls $modulePath /reset
    # grant permissions to Administrators group, but use SID to do
    # it because it is localized on non-us installations of Windows
    icacls $modulePath /grant "*S-1-5-32-544:F" /inheritance:d /T
    Remove-Item -Path $modulePath -Recurse -Force -Confirm:$false
    23 changes: 23 additions & 0 deletions Uninstall-Pester3.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #Requires -RunAsAdministrator
    $pesterPaths = foreach ($programFiles in ($env:ProgramFiles, ${env:ProgramFiles(x86)}))
    {
    $path = "$programFiles\$suffix\WindowsPowerShell\Modules\Pester"
    if ($null -ne $programFiles -and (Test-Path $path)) {
    Get-ChildItem "$path\3.*"
    }
    }


    if (-not $pesterPaths) {
    "There are no Pester 3 installations in Program Files and Program Files (x86) doing nothing."
    continue
    }

    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
    }
  4. nohwnd revised this gist Dec 8, 2019. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion Uninstall-Pester.ps1
    Original file line number Diff line number Diff line change
    @@ -8,5 +8,7 @@ if (-not (Test-Path $modulePath)) {

    takeown /F $modulePath /A /R
    icacls $modulePath /reset
    icacls $modulePath /grant Administrators:'F' /inheritance:d /T
    # grant permissions to Administrators group, but use SID to do
    # it because it is localized on non-us installations of Windows
    icacls $modulePath /grant "*S-1-5-32-544:F" /inheritance:d /T
    Remove-Item -Path $modulePath -Recurse -Force -Confirm:$false
  5. nohwnd revised this gist Dec 11, 2018. No changes.
  6. nohwnd created this gist Dec 9, 2017.
    12 changes: 12 additions & 0 deletions Uninstall-Pester.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #Requires -RunAsAdministrator
    $modulePath = "C:\Program Files\WindowsPowerShell\Modules\Pester"

    if (-not (Test-Path $modulePath)) {
    "There is no Pester folder in $modulePath, doing nothing."
    break
    }

    takeown /F $modulePath /A /R
    icacls $modulePath /reset
    icacls $modulePath /grant Administrators:'F' /inheritance:d /T
    Remove-Item -Path $modulePath -Recurse -Force -Confirm:$false