Open Files Report for your file servers

Here is simple function to generate report on open files on your file servers

#Script: Report Open Files on all file servers
#Author: Vojin Lekovic (

$FileServers = "SERVER1","SERVER2","SERVER3"

Function OpenFilesReport($Servers)
    #Properties to include
    $property = "Hostname","ID","Accessed By","Type","#Locks","Open Mode","Open File (Path\executable)"

    #Script block to execute on each server
    $block = {
        openfiles /query /fo CSV /v | select -Skip 8 | ConvertFrom-Csv

    #Connect to all servers
    $Session = New-PSSession -ComputerName $Servers

    #Run script block on each server
    Invoke-Command -Session $Session -ScriptBlock $block | Select-Object -Property $property

    #Close all sessions
    $Session | Remove-PSSession

#How to use:
#Report number of oppened files per server
OpenFilesReport $FileServers | group HostName | select @{n='Date';e={get-date}}, Name, Count;
#Report number of oppened files per user
OpenFilesReport $FileServers | group "Accessed By" | select @{n='Date';e={get-date}}, Name, Count;
#Report total number of connected users
OpenFilesReport $FileServers | group "Accessed By" | measure | select Count
#Report Y drive oppened files per server