This is an old question, but nevertheless:
if you have PowerShell 4.0+ (which does not come with Windows Server 2008, you would have to update your PowerShell Version), you could use this:
Directly on the server:
Get-SmbOpenFile | where-object { $_.Path -like 'C:\foo\bar\*' }
from a RemoteMachine:
$cim = New-CimSession ServerName -Credential (get-credential)
Get-SmbOpenFile -CimSession $cim | where-object { $_.Path -like 'C:\foo\bar\*' }
Get-SmbOpenfile
returns a list of all open files on the server, which we filter with where-object
to only see the ones we're looking for.
This will return amongst other things the ClientComputerName
which is the IP of the computer that has opened the file.
Here's an example output:
PS C:\WINDOWS\system32> get-smbopenfile -cimsession $cim | where-object { $_.Path -like 'D:\Daten\Transfer\*' }
FileId SessionId Path ShareRelativePath ClientComputerName ClientUserName PSComputerName
------ --------- ---- ----------------- ------------------ -------------- --------------
347355680805 348160786757 D:\Daten\TRANSFER\xy TRANSFER\xy 10.0.0.114 INTERNAL\xy Server
If you then want to quickly see what's the hostname of the returned IP-Address, use:
[Net.DNS]::GetHostByAddress("10.0.0.114") | select -expand HostName