In this article, I will explain how to view from a Windows server open shared files / folders.
There are two ways to access open files / folders in either graphical or command-line mode using PowerShell.
PowerShell
List open folders / files:
Get-SmbOpenFile
Result :
FileId SessionId Path ShareRelativePath ClientComputerName ClientUserName ------ --------- ---- ----------------- ------------------ -------------- 122675006077 122876330697 C:windowsSYSVOLsysvol 10.0.0.50 LABAdministrateur
Detail 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, display only vhdx files
![](https://rdr-it.com/wp-content/uploads/2020/11/fileopenfilter-600x137.png)
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
Graphic
1. Open the local computer manager.
![](https://rdr-it.com/wp-content/uploads/2019/03/open-file-01-201x400.png)
2. Go to Shared Folders 1 .
![](https://rdr-it.com/wp-content/uploads/2019/03/open-file-02-600x142.png)
This folder contains 3 subfolders:
– Shares: to display the list of available shares on the server and administration (add / modify / delete) .
– Sessions: displays the list of users who have access to shared items
– Open files: displays the list open files.
3. Go to the Open Files 1 folder to view open files.
![File open](https://rdr-it.com/wp-content/uploads/2019/03/open-file-03-600x164.png)
To close access to the file, right-click on the file and click Close open file.
4. Go to the Sessions 1 folder. This page displays the users connected with the computer and the number of open files.
![Sessions](https://rdr-it.com/wp-content/uploads/2019/03/open-file-04-600x144.png)
As for the files, it is possible to act on the sessions by right click on it.