Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Shared folder Audit with a script. Record the Shared folder size in an csv or excel.

Hi,

Shared folder Audit with a script. Record the Shared folder size in an csv or excel.
Attached is a sample sheet.
I want a script that i can schedule when run checks all shared folders and records the size in the colum.

So i know which folder when has taken up space. To monitor the shares this would be an excellent help...

Any excel, Batch or vbs script has can do this.
Regards
Sharath
Sample.xls
Avatar of tigermatt
tigermatt
Flag of United Kingdom of Great Britain and Northern Ireland image

Try this. It doesn't write to an Excel file - it simply outputs to a text logfile at a path you specify.

You need to enter the shares to be monitored on each line in a text file. Specify the path to this file in the Const rootFolders entry. The logging path is then the Const logFile entry.

Matthew
'Variables
Const rootFolders = "C:\rootFolders.txt"
Const logFile = "C:\logfile.txt"
 
' *****
 
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
 
If fso.FileExists(rootFolders) = 0 Then
	MsgBox("No list of root folders")
	WScript.Quit
End If
Dim objrootFolders: Set objrootFolders = fso.OpenTextFile(rootFolders, 1)
Dim logFileObj: Set logFileObj = fso.CreateTextFile(logFile, True)
 
Do while not objrootFolders.AtEndOfStream
	strFolder = objrootFolders.ReadLine
	'MsgBox(strFolder)
	If fso.FolderExists(strFolder) = True Then
		logFileObj.WriteLine(strFolder & " -- " & (fso.GetFolder(strFolder).Size/1000/1000) & " MB")
	Else
		logFileObj.WriteLine (strFolder & " -- Does not exist!")
	End If
Loop
 
MsgBox("Complete")

Open in new window

Avatar of bsharath

ASKER

Thanks mathew

But the size appears as this for a 2.37 MB i get this (2.488644 MB) Can this be changed.
When i run the 2nd time i get the old data erased and new data is inserted.

As this is going to have a log file.
Can this create new files every time i run the script with the date and time. So later i can move all to an excel to compare.

It would be good if the script can find the shares automatically....
Thanks mathew

But the size appears as this for a 2.37 MB i get this (2.488644 MB) Can this be changed.
When i run the 2nd time i get the old data erased and new data is inserted.

As this is going to have a log file.
Can this create new files every time i run the script with the date and time. So later i can move all to an excel to compare.

It would be good if the script can find the shares automatically....
ASKER CERTIFIED SOLUTION
Avatar of tigermatt
tigermatt
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Matthew works great...
Good :)
Avatar of wdedeaux
wdedeaux

Thank you for the script post this would be very helpful. I am however getting a script error of object not found  line 18 ch17 after the script has written just 3 entries.  Is it the log file not being found or the pc share?