Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to know about how many people are in using a file shared on my computer and have full report about it.

share|improve this question

2 Answers 2

up vote 8 down vote accepted

For this purpose, go to File Server Manager like as picture one. In this section go to Run and type

fsmgmt.msc

and press enter. As you can see in picture, all of shared folders and number of clients in Shares part are visible. Also you can see the names of those who are connected to your computer in Sessions part and information about Open Files part.

Picture 1

As well as you can use

net share

command in Windows cmd like as picture two.

Picture 2

share|improve this answer
    
you can also use net file to list files from command line –  wmz Oct 5 '12 at 13:42

There are two Powershell WMI classes that can be used to obtain this information as well. The Win32_Shares class will show you information about the folders you have shared on your computer, or a remote computer. It's used like this:

Get-WmiObject -class Win32_Shares

Or remotely:

Get-WmiObject -class Win32_Shares -computerName {SERVERNAME}

You can also view very specific connection information with the Win32_SessionConnection object. It will show information about each connection active to shares. The user, the computer name and the IP address. It's used like this:

Get-WmiObject -class Win32_SessionConnection -computerName {SERVERNAME} | Select Dependent

The output of the command is piped through select dependent because it reports more information than you need for the purposes of this question. As such you can pipe it through Select-Object (shortened to select) to grab a specific property from each object returned by the WMI query.

On our production file server, running the query returned 636 active connections. You can get a count by piping the output of the last command through Measure-Object.

Get-WmiObject -class Win32_SessionConnection -computerName {SERVERNAME} | Select Dependent | Measure-Object

enter image description here

Hope you find this information useful.

I took this a little further... Here's something you can paste into PowerShell for output that's a little easier to read. You'll have to run PowerShell with elevated privileges to access the Win32_SessionConnection object. Be sure to change the value of the $server variable at the top of the snippet.

$server = 'CHANGEME' ## <--CHANGE THIS STRING VALUE

function __construct($proparray) {
    $rtnObj = new-object PSCustomObject;
    $rtnObj | add-member -type noteproperty -name 'ip' -value $proparray[0];
    $rtnObj | add-member -type noteproperty -name 'share' -value $proparray[1];
    $rtnObj | add-member -type noteproperty -name 'user'-value $proparray[2];
    return $rtnObj
}

$cnxArray = @();

gwmi win32_sessionconnection -computer $server|select dependent|% { $cnxArray += __construct([string]$_ -replace '\@\{|\}|\"|[A-Za-z\.]+=|Win32_','').split(",") }

$cnxArray;
## You may have to press enter if this last line does not process with the paste.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.