mikemaccana mikemaccana - 1 year ago 260
PowerShell Question

fuser equivalent in Powershell?

I want to delete a directory, but a process is using it.

mv : Access to the path 'C:\Users\mike\Documents\myapp\node_modules\' is denied.

Explorer mentions the dir is in use. Is there a Windows Powershell equivalent of

Note this is a powershell question. I don't want to launch a GUI app.

Answer Source

Try this one:

Get-Process | %{$processVar = $_;$_.Modules | %{if($_.FileName -like "$lockedFolder*"){$processVar.Name + " PID:" + $processVar.id}}}

This looks for every process that's running in the folder.

I think there is no equivalent to fuser, but there is a tool called handle.exe that has to be installed first.

PowerShell script to check an application that's locking a file?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download