& net session | ? { $_ -match '^(\S+)\s+(\w+)\s+(.*)\s+(\d+)\s+(\S+)\s*$' } | % {
New-Object -Type PSObject -Property @{
'Client' = $matches[1]
'User' = $matches[2]
'Type' = $matches[3].Trim()
'Open' = $matches[4]
'Idle' = $matches[5]
}
}
& net file | ? { $_ -match '^(\d+)\s+(.*)\s+(\w+)\s+(\d+)\s*$' } | % {
New-Object -Type PSObject -Property @{
'ID' = $matches[1]
'File' = $matches[2].Trim()
'User' = $matches[3]
'Locks' = $matches[4]
}
}
#http://stackoverflow.com/questions/29209972/monitor-shared-file-access-using-powershell
Comments