Solved

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

Posted on 2008-09-29
7
658 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:bsharath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 58

Expert Comment

by:tigermatt
ID: 22598809
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

0
 
LVL 11

Author Comment

by:bsharath
ID: 22602439
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....
0
 
LVL 11

Author Comment

by:bsharath
ID: 22602440
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....
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 58

Accepted Solution

by:
tigermatt earned 500 total points
ID: 22603244
Here you go.

MB is now rounded to 2 DP. Log Files made by Date. And Shares found automatically.

:)
'Variables
Const logFileRoot = "C:\CanoScan\" 'Logfiles will be made here WITH trailing \
 
' *****
 
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
 
Dim logFileObj: Set logFileObj = fso.CreateTextFile(logFileRoot & Year(Date()) & "-" & MonthName(Month(Date()),3) & "-" & Day(Date()) & " " & Hour(Time()) & "." & Minute(Time()) & "." & Second(Time()) & ".log", True)
 
strComputer = "."
Dim objWMIService: Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Dim pcShares: Set pcShares = objWMIService.ExecQuery("Select * from Win32_Share")
 
For each objShare in pcShares
	If not Right(objShare.Name, 1) = "$" Then
        	strFolder = objShare.Path
        	'MsgBox(strFolder)
                logFileObj.WriteLine(strFolder & " -- " & Round((fso.GetFolder(strFolder).Size/1000/1000),2) & " MB")
   
	End If
Next
 
MsgBox("Complete")

Open in new window

0
 
LVL 11

Author Comment

by:bsharath
ID: 22603277
Thanks Matthew works great...
0
 
LVL 58

Expert Comment

by:tigermatt
ID: 22607570
Good :)
0
 

Expert Comment

by:wdedeaux
ID: 25952980
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?
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mirrorEnds challenge 6 145
maxBlock challenge 30 145
either24  challenge 19 105
what is the main difference between git clone and fetch ann pull and push commands 2 113
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
This article will show, step by step, how to integrate R code into a R Sweave document
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question