0

I'm trying to delete an empty folder via Powershell. I can delete the folder manually w/o any issues but when I try to run the following PS command I get the error:

enter image description here

the PS command is Remove-Item "C:\Program Files\P...Ware" -Force;


update

I followed @Captain's advise and still got the same error:

enter image description here

Robert Green MBA
  • 1,834
  • 1
  • 22
  • 45

2 Answers2

1

This solution may work for you:

$allProcesses = Get-Process
#$lockedFile is the file path
foreach ($process in $allProcesses) { 
$process.Modules | where {$_.FileName -eq $lockedFile} | Stop-Process
-Force -ErrorAction SilentlyContinue
    }
Remove-Item $lockedFile

from

https://stackoverflow.com/a/45714289/10958914

Captain
  • 420
  • 5
  • 14
-1

You have to provide the -path parameter as well

Remove-Item -path "yourfolder path" -force

Your command will be like this

Remove-Item -path "C:\Program Files\P...Ware" -Force;