
In this tutorial, I will explain how to see from a Windows server, the shared files and folders that are open.
There are two ways to access the view of open files and folders, in graphical mode or in command line with PowerShell.
Table Of Content
View open files and folders with PowerShell
List Open Folders and Files with the PowerShell Cmdlet Get-SmbOpenFile :
Get-SmbOpenFile
Result :
FileId SessionId Path ShareRelativePath ClientComputerName ClientUserName ------ --------- ---- ----------------- ------------------ -------------- 122675006077 122876330697 C:windowsSYSVOLsysvol 10.0.0.50 LABAdministrateur
Details on a file:
Get-SmbOpenFile -FileId <!ID-FICHIER!> | Select-Objet -Property *
Result :
SmbInstance : Default
ClientComputerName : 10.0.0.50
ClientUserName : LABAdministrateur
ClusterNodeName :
ContinuouslyAvailable : False
Encrypted : False
FileId : 122675006077
Locks : 0
Path : C:windowsSYSVOLsysvol
Permissions : 1048705
ScopeName : *
SessionId : 122876330697
ShareRelativePath :
Signed : True
PSComputerName :
CimClass : ROOT/Microsoft/Windows/SMB : MSFT_SmbOpenFile
CimInstanceProperties : {ClientComputerName, ClientUserName, ClusterNodeName, ContinuouslyAvailable...}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties
Filter the list of open files:
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match ".vhdx"
The above command only displays vhdx files

Close an open file:
Close-SmbOpenFile -FileId <!FILE-ID!>
Result: Confirm the action.
Confirmer Êtes-vous sûr de vouloir effectuer cette action ? Opération « Close-File » en cours sur la cible « 122675006077 ». [O] Oui [T] Oui pour tout [N] Non [U] Non pour tout [S] Suspendre [?] Aide (la valeur par défaut est « O ») : O
View open files and folders from the GUI
Open Local Computer Manager.

Go to Shared Folders 1.

This folder contains 3 subfolders:
- Shares: allows you to display the list of shares available on the server as well as administration (addition / modification / deletion).
- Sessions: displays the list of users who have access to shared items
- Open files: displays the list of open files.
Go to the Open Files folder 1 to display the open files.

To close access to the file, right-click on the file and then click Close Open File.
Go to the Sessions 1 folder. This page displays the users logged in to the computer and the number of open files.

As with files, it is possible to act on sessions by right-clicking on the folder.
