QuickTip: Use WMI to determine remote users accessing files and shares

A question popped up on the PowerShell.com forums, asking if it was possible to view a list of users accessing network shares on a system. It turns out this is a relatively easy task using WMI

Get-WmiObject -Class Win32_ServerConnection -ComputerName server01

Now this does output a large amount of data, so I would recommend filtering some of the more useful properties for example:

Get-WmiObject -Class Win32_ServerConnection -ComputerName server01 |
Select-Object -Property ComputerName,ConnectionID,UserName,ShareName

Of course it is also possible to query for this information using the newer Get-CimInstance cmdlet:

Get-CimInstance -Class Win32_ServerConnection -ComputerName server01

There you have it, accessing the full list of users from a local or remote system that are accessing shared folders on the system is quite easily done when using PowerShell.


Leave a Reply