Advertisement
keebz

Manage Open Files - PS on Server 2008 R2

Mar 31st, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. & net session | ? { $_ -match '^(\S+)\s+(\w+)\s+(.*)\s+(\d+)\s+(\S+)\s*$' } | % {
  2.   New-Object -Type PSObject -Property @{
  3.     'Client' = $matches[1]
  4.     'User'   = $matches[2]
  5.     'Type'   = $matches[3].Trim()
  6.     'Open'   = $matches[4]
  7.     'Idle'   = $matches[5]
  8.   }
  9. }
  10.  
  11. & net file | ? { $_ -match '^(\d+)\s+(.*)\s+(\w+)\s+(\d+)\s*$' } | % {
  12.   New-Object -Type PSObject -Property @{
  13.     'ID'    = $matches[1]
  14.     'File'  = $matches[2].Trim()
  15.     'User'  = $matches[3]
  16.     'Locks' = $matches[4]
  17.   }
  18. }
  19.  
  20. #http://stackoverflow.com/questions/29209972/monitor-shared-file-access-using-powershell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement