Advertisement
Combreal

Get-LockingProcess.ps1

Apr 11th, 2022
1,229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #The openfiles command needs to have support for local files enabled, by running openfiles /local on and restarting.
  2.  
  3. $FileOrFolderPath = "C:\Temp\blaireau-mag-11042022.avi"
  4.  
  5. If ((Test-Path -Path $FileOrFolderPath) -eq $false) {
  6.     Write-Warning "File or directory does not exist."      
  7. }
  8. Else {
  9.     $LockingProcess = CMD /C "openfiles /query /fo table | find /I ""$FileOrFolderPath"""
  10.     Write-Host $LockingProcess
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement