Monitor Share Usage for File Server Migration


I needed a way to monitor the usage of particular shares on a file server as we are looking to move to a clustered file server, and you need to create a resource for every share. 


Our existing file server has many shares on it, but most of them are unused, as we point most users through DFS.  I could not find any way of collating information as to which SHARES where used to connect to a particular file, as auditing only tells you which files are actually accessed.  To this end, I wrote a simple vb script which creates a comma delimited file with the maximum usage record for each share.  It does not tell uswho has accessed each share, but it gives us a starting point to find out which shares need to be kept, or which users we need to educate not to use the shares when we migrate.


The script below accomplishes the task.  Leave it running for a few days then view the CSV file in Excell…


————————————————————————————————–


‘ Name:       sharemon.VBS


‘ Purpose:    To monitor share path usage on a file server



‘Written by Leon Funnell


’email me at leon_funnell(At)hotmail(d0t)com


’22/03/2005



 


 


‘ check command line


GetArgs strComputername,strOutputFile,CorrectSyntax


If CorrectSyntax Then


       Set fso = CreateObject(“Scripting.FileSystemObject”)


       wscript.echo “Monitoring Share usage on “ & strComputername & ” To file “ & strOutputFile


       wscript.echo “Press CTRL-C To Stop…”


       wscript.echo “”


       Set fs = GetObject(“WinNT://” & strComputername & “/LanmanServer”)


       Dim ShareList(500,3)


       Sharenum = 1


‘ Populate ShareList with name, path, and CurrentUserCount of each share


       For Each share In fs


              ShareList(sharenum,1) = share.name


              ShareList(sharenum,2) = share.path


              ShareList(sharenum,3) = share.CurrentUserCount


              Sharenum = Sharenum + 1


       Next


      


writeArray ShareList, strOutputFile, sharenum


‘ Now monitor the shares on the server to watch for any upward movement on the CurrentUserCount for each share


       Do


       Sharenum = 1


       For Each share In fs


              If ShareList(sharenum,3) < share.CurrentUserCount Then


                     ShareList(sharenum,3)=share.CurrentUserCount


              End If


              Sharenum = Sharenum + 1


       Next


       writeArray ShareList, strOutputFile, sharenum


       wscript.echo “.”


       Wscript.Sleep 5000


       Loop


Else


       DisplayHelp


       wscript.quit


End If


 


Sub GetArgs(strComputername,strOutputFile,CorrectSyntax)


       Set Args = WScript.Arguments


       If args.count = 2 Then


              CorrectSyntax = True


              strComputername= args(0)


              strOutputFile= args(1)


       Else


              CorrectSyntax = False


       End If


End Sub


 


 


Sub DisplayHelp


       wscript.echo “Keeps a count of the maximum number of accesses to particular shares on a File server”


       wscript.echo “adn logs it to a file”


       wscript.echo “cscript sharemon.VBS /? or /Help ———————————– Displays this help screen”


       wscript.echo “cscript sharemon.VBS Servername”


       wscript.echo “”


End Sub


 


Sub writeArray(arr,writeFile,iLines)


       Set file = fso.openTextFile(writeFile, 2, True)


       For i = 1 To iLines


              file.writeLine arr(i,1) & “,” & arr(i,2) & “,” & arr(i,3)


       Next


       file.close


       Set file=Nothing


end sub

About The Author

1 thought on “Monitor Share Usage for File Server Migration”

  1. Well this is a easy thing and is provided in GS Richcopy 360, which I am currently using to handle file server migrations. Along with the above feature it keeps the file permissions of the files after the transfer is complete!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top