none
Find out who is opening a file RRS feed

  • Question

  • Good day,

     

    Is there a way to find out who is opening a file using the powershell instead of going to the open files in the computer manager?

     

    best regards,

    Abdullah

    Tuesday, September 6, 2011 12:48 PM

Answers

  • Hi,

    I guess net.exe file has problems with long path....

    You can try this instead...

    openfiles /query  /v  | select-string -pattern '<filename>'
    

    To run on a remote system, you can try this:

    $s = new-pssession -computername <servername>; invoke-command -session $s -scriptblock { openfiles.exe /query /v } | select-string -pattern '<filename>'
    


    This will run if WinRM is enabled and firewall isn't blocking remote access.

    And running against a NAS system will work if NAS is Windows Storage Server.

     

     


    Thanks, Wilson Souza - MSFT This posting is provided "AS IS" with no warranties, and confers no rights
    Tuesday, October 18, 2011 8:37 AM
    Moderator

All replies

  • You can try handle.exe from sysinternals.com.

    http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx

    Or Alternately you can us openfiles.exe which is a built in command.


    Regards Mukul Shekhawat [MSFT] This posting is provided AS IS, with no warranties, and confers no rights.
    Tuesday, September 6, 2011 4:42 PM
  • many thanks for your replying to my question but these 2 commands will show all open files. I want to check only one file who open it to contact him to close it so that other user can edit it.
    Saturday, September 10, 2011 4:39 AM
  • many thanks for your replying to my question but these 2 commands will show all open files. I want to check only one file who open it to contact him to close it so that other user can edit it.

    Openfiles may work for what you need.

    http://technet.microsoft.com/en-us/library/cc732490%28WS.10%29.aspx


    My Blog | www.buchatech.com | www.dpm2010.com
    Tuesday, October 11, 2011 3:21 AM
    Moderator
  • Hi Abdullah Al-Nemer,

     

    You can try this from PowerShell with admin privileges:

    net.exe file | select-string -pattern '<filename>'
    

    This will list the username that has the <filename>  opened....


     

     


    Thanks, Wilson Souza - MSFT This posting is provided "AS IS" with no warranties, and confers no rights
    Tuesday, October 18, 2011 6:50 AM
    Moderator
  • Many thanks Wilson for passing and providing the solution.

    I have one concern. How can I run this command against a remote computer? Also, can it be used against NAS system?

     

     

    Tuesday, October 18, 2011 7:45 AM
  • Hi,

    I guess net.exe file has problems with long path....

    You can try this instead...

    openfiles /query  /v  | select-string -pattern '<filename>'
    

    To run on a remote system, you can try this:

    $s = new-pssession -computername <servername>; invoke-command -session $s -scriptblock { openfiles.exe /query /v } | select-string -pattern '<filename>'
    


    This will run if WinRM is enabled and firewall isn't blocking remote access.

    And running against a NAS system will work if NAS is Windows Storage Server.

     

     


    Thanks, Wilson Souza - MSFT This posting is provided "AS IS" with no warranties, and confers no rights
    Tuesday, October 18, 2011 8:37 AM
    Moderator
  • It is really helpful this command (openfiles) but there are one problem with it. If you want to close specific file using the ID number, it will not be closed since the ID number is not completed.

    I have found another command psfiles.exe. It is good one.

     

    many thanks for your support.

    Tuesday, October 25, 2011 12:45 PM