I’m trying to remove pester v3.4.0 but nothing I’m doing is working. I can’t manually remove the folder as admin. I can’t run uninstall-module normally or as admin and I can’t use this script:
# folders where PowerShell looks for modules:
$paths = $env:PSModulePath -split ';'
# finding actual module folders
$modules = Get-ChildItem -Path $paths -Depth 0 -Directory | Sort-Object -Property Name
$modules |
Select-Object -Property Name, @{N='Parent';E={$_.Parent.FullName}}, FullName |
Out-GridView -Title 'Select module(s) to permanently delete' -PassThru |
Out-GridView -Title 'Do you REALLY want to remove the modules below? CTRL+A and OK to confirm' -PassThru |
Remove-Item -Path { $_.FullName } -Recurse -Force
I just keep getting the following for every file in the folder.
+ Remove-Item -Path { $_.FullName } -Recurse -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (3.4.0:DirectoryInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Cannot remove item C:Program FilesWindowsPowerShellModulesPester: The directory is not empty.
At line:5 char:3
I’ve tried it running from an elevated powershell prompt, a normal powershell prompt, an elevated pwsh7.4.2 prompt and a normal one as well. I’ve even tried it from VSCode normal and elevated. I also tried to just delete the folder from the directory! Does anyone have any ideas? I’m out.
I even ran Get-Process -Name $ProcName | kill -force with powershell and pwsh to make sure there weren’t any errant processes running amuck. I killed all versions of VSCode running too. And I, of course, rebooted.
This is the output from get-module -listavailable
get-module -listavailable | where name -EQ 'pester'
Directory: C:Program FilesWindowsPowerShellModules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 3.4.0 Pester {Describe, Context, It, Should...}
1
This worked!
$modulePath = "C:Program FilesWindowsPowerShellModulesPester"
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
Then I re-installed it with Install-Module Pester -Force -Scope CurrentUser and I’m up to 5.6.1 now.