Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cleanup Network Shares - Find Shares - Security

Status
Not open for further replies.

bence8810

IS-IT--Management
Jul 20, 2005
241
0
0
AE
Dear All,

I have been tasked to clean up all of our network shares, and to make sure there is no illegal content on any of our workstations, all 200 of them. One by one this is obviously tedious. On the Network shares, I can do a search, but is there a way to search the individual workstations? Maybe some indexing software that kicks in on every reboot?

I am also looking for some tool to find shares on our LAN, in case some "smart" user puts up a collection of MP3's and shares it with his/her buddies.

Any help would be greatly appreciated. If I could do something through GPO, that would be even better.

Thanks a lot,

Ben
 
I'm using EZ Audit, gives details on shares, installed software etc.
Try google [vbscript find all shares], with any of the scripts you find that work for you, you could use it as a logon script and write the information to a logfile.
 
found 2 that may help
Code:
'*************************************************************
'		Script Witten by Larry Heintz       	    
'		March 2006 [URL unfurl="true"]www.windowsadminscripts.com[/URL]
' This script will reveal all user and hidden shares on a
' computer. It will show you the share name, share comment
' and share path. You will also have the option to run the 
' script against a AD Domain or Work Group name. The script
' also saves the shares information into a comma delimited
' file.
'
' Script Usages:
' List Shares on Single PC: cscript shares.vbs /computer:[computername]
' List Shares on AD Domain/Work Group: cscript shares.vbs /adwg:[ad domain or workgroup name]
'*************************************************************
Dim objStdOut,args
Dim computername,adwg
Set args = Wscript.Arguments.Named
computername = args.Item("computer")
adwg = args.Item("adwg")
logpath = getLogPath()

if wscript.arguments.count = 0 then
	wscript.echo "Script Usages:"
	wscript.echo "List Shares on Single PC: cscript shares.vbs /computer:[computername]"
	wscript.echo "List Shares on AD Domain/Work Group: cscript shares.vbs /adwg:[ad domain or workgroup name]"
elseif args.exists("computer") then
	Call listShares(computername)
elseif args.exists("adwg") then
	Call listSharesADWG(adwg)
end if

Function listShares(computername)
On Error Resume Next
Dim objshares,share
set objshares = GetObject("winmgmts:{impersonationLevel=impersonate}\\" & computername & "\root\cimv2").ExecQuery("SELECT * FROM Win32_Share")
wscript.echo "Shares for " & ucase(computername) & vbcrlf
wscript.echo "Name" & space(11) & "Comment" & space(13) & "Path"
wscript.echo "=====" & space(10) & "========" & space(12) & "====="
for each share in objshares
	Call writeLog(computername,share.name,share.caption,share.path)
	wscript.echo share.name & space(15-(len(share.name))) & share.caption & space(20-len(share.caption)) & share.path
next
set objshares = nothing
wscript.echo ""
End Function

Function listSharesADWG(adwg)
set container = getobject("WinNT://" & adwg)
container.filter = array("computer")
for each computer in container
	listShares(computer.name)
next
set container = nothing
End Function

Function getLogPath()
Dim temp,temp2
temp = split(wscript.scriptfullname,"\")
for i = 0 to ubound(temp) - 1
	temp2 = temp2 & temp(i) & "\"
next
getLogPath = temp2
End Function

Function writeLog(computername,sharename,sharecomment,sharepath)
Dim FSO,objFSOwriteline
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objFSOwriteline = FSO.OpenTextFile(getLogPath() & "\shares.log", 8,True)
	objFSOwriteline.WriteLine(computername & "," & sharename & "," & sharecomment & "," & sharepath)
	objFSOwriteline.close
Set objFSOwriteline = nothing
Set FSO = nothing
End Function

Code:
' --------------------------------------------------------
'           ScriptingAnswers.com ScriptVault
' --------------------------------------------------------
' Entry title: ListShares
'      Author: Don Jones
'      E-mail: don@scriptinganswers.com
'
' Brief desscription:
' Lists the shares (and physical paths of the shares)
' on a computer. Reads in computers names from a file.
'
'
'
' --------------------------------------------------------
' Version history:
' 1.0   02/17/2006  Initial release
'
' --------------------------------------------------------
' The user of this script accepts all responsibility For
' reviewing, testing, and using it, and specifically 
' holds harmless ScriptingAnswers.com, SAPIEN Technologies,
' and the script's original author from any damages which
' result from the use of this script, including any
' direct, consequential, or indirect damages which may
' result.
' --------------------------------------------------------


' --------------------------------------------------------
' DOCUMENTED DEPENDENCIES
' Things this script relies on or assumes are already
' in place, apart from things which are built into 
' WinXP or later:
' 
' --------------------------------------------------------

Option Explicit
Dim strFile, objFSO, objTS, strComputer
Dim objWMI, colResults, objResult, strWMIQuery
Dim strOutput, colResults2, objResult2, strWMIQuery2

strFile = "C:\wslist.txt"

On error resume next
' MAIN SCRIPT CODE
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFile) Then
	Set objTS = objFSO.OpenTextFile(strFile)
	Do Until objTS.AtEndOfStream
		strComputer = objTS.ReadLine
		Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
		strWMIQuery = "SELECT * FROM Win32_Share"
		Set colResults = objWMI.ExecQuery(strWMIQuery)
		For Each objResult In colResults
			strOutput = strComputer & " - " & objResult.Name & " = " & objResult.Path
			strWMIQuery2 = "SELECT * FROM Win32_Directory WHERE Name = '" & _
			 Replace(objResult.Path,"\","\\") & "'"
			Set colResults2 = objWMI.ExecQuery(strWMIQuery2)
			For Each objResult2 In colResults2
				strOutput = strOutput & " (" & objResult2.FSName & ")"
			Next
			WScript.Echo strOutput
		Next
	Loop
End If
objTS.Close
WScript.Echo "Complete"
 
Hi

Thanks guys, I am using the first script from the two.

I basially need to check the shares on specific PCs, so I cannot use the Domain option, but I need to do it on quite a few, so some batch would be nice.

This command to execute it would look like this:

Code:
cscript CheckShare-Local.vbs /computer:%pcname%

and I would like to read the %pcname% from a text file. How would this be possible?

Thanks for any help,

Ben
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top