• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1258
  • Last Modified:

Batch file wanted to list all shares on network by servername/share

I have a network with several hundred Windows 2003 servers.  I need to get a list of all of the network shares by servername.  I am hoping this can be done by using a batch file.

Preferrably, I would like to have a text file that lists each server name.  The batch file would take each server name, check the server, and then append an output text file with the shares for that server.  It would then continue down the server list until it reached the end.  The text file would look something like this:

SERVER1\SALES\
SERVER1\OPERATIONS\
SERVER1\DEVELOPMENT\
SERVER2\ADMIN\
SERVER2\FINANCE\

The exact format doesn't matter as much as just being able to collect the information in a text file.
0
Steve
Asked:
Steve
1 Solution
 
DabecsCommented:
From WinDrivers forum...
I will be making use of this myself.

net view /domain:Your_Domain>>machinelist.txt
for /f %%i in (machinelist.txt) do net view %%i>>shares.txt
del machinelist.txt
0
 
SteveAuthor Commented:
Exactly what I needed, Dabecs.  Thanks!
0
 
AmericomCommented:
Here is a script I recently created myself which would do what you need:
All you need is a file(input file) list all ther servers which can be easily obtained from many different sources, even with ADCU's export list feature. The other file is the output file which will automatically be created with info as you needed: ServerName, ShareName & Path. Each servername will be separated by a line. I inlcuded the path thinking that it may be useful for you but you can take it out as you wish.
Hope this help.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\temp\ServerList-Out.txt")
objFile.Close
Set objFileIn = objFSO.OpenTextFile("C:\temp\ServerList-In.txt", 1)
Const ForAppending = 8
Set objFileOut = objFSO.OpenTextFile("C:\temp\ServerList-Out.txt", ForAppending)
 
 
Do Until objFileIn.AtEndOfStream
 
 
 	strLine = objFileIn.ReadLine
 
 
	On Error Resume Next
	strComputer = strLine
	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_Share",,48)
 
 
	objFileOut.WriteLine "ServerName: " & strComputer
	
	For Each objItem in colItems
    
 
    		objFileOut.WriteLine "ShareName: " & objItem.Name
    		objFileOut.WriteLine "Path: " & objItem.Path
 
	Next
	
	objFileOut.WriteBlankLines(1)
 
 
Loop
 
objFileIn.Close
objFileOut.Close

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now