4.24. Viewing Shares


You want to view the list of shares on a server.


Using a graphical user interface

  1. Open the Computer Management snap-in.

  2. In the left pane, expand System Tools Shared Folders Shared Folders.

  3. To view the properties of a share, double-click on it in the right pane. To disable a share, right-click on it and select Stop Sharing.

Using a command-line interface

The following command displays administrative and nonadministrative shares:

> net share

To view the list of shares on a remote server, use the Sysinternals psexec.exe utility to run the net share command against the server:

> psexec \\<ServerName> -u <User> net share

For example:

> psexec \\srv01 -u administrator net share

You can also view all of the nonadministrative shares on a remote server using this command:

> net view \\<ServerName>

Using VBScript

' This code displays all of the shares on a system.
strComputer = "."
' ------ END CONFIGURATION ---------
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colShares = objWMI.InstancesOf("Win32_Share")
for each objShare in colShares
   WScript.Echo objShare.Name 
   WScript.Echo "  Path:        " & objShare.Path 
   WScript.Echo "  Allow Max:   " & objShare.AllowMaximum 
   WScript.Echo "  Caption:     " & objShare.Caption 
   WScript.Echo "  Max Allowed: " & objShare.MaximumAllowed
   WScript.Echo "  Type:        " & objShare.Type 


The Sysinternals Shareenum program is another tool that you can use for viewing shares. It lists the shared folders on all hosts in a particular domain. Depending on the number of hosts in the domain, it can take a while to complete. It is interesting to see the output and discover what types of shared folders users have created. You may even want to periodically check the security on these shared folders to ensure that users are following your documented policies for shared folder security.

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.