Recipe4.24.Viewing Shares


Recipe 4.24. Viewing Shares

Problem

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

Solution

Using a graphical user interface

  1. Open the Computer Management snap-in.

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

    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. ' ------ SCRIPT CONFIGURATION ------ 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     WScript.Echo next

Discussion

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.



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net