Hi guys, I'm completely new to this
vbscripting scene. From the loads of information I've looked up so far,
it seems like vbscripting is ideal for a lot of simple to moderately
complex Windows administrative tasks (right?). I want to know how to go
about tackling this problem I have via vbscript... From
what I gather, there are a lot of predefined disk quotas scripts
available. They'll do things like turn on disk quotas, enforce disk
quotas, list disk quotas for all users, etc... What we want
to do is transverse a big list of users on a Windows 2003 File Server
(has about 900GB of data) and come up with a list of users, figure out
the average disk usage per user, and see whether this is a sane limit
to impose on users or not (or figure out a sane limit from those
figures). From there, we want to generate a list of the biggest disk
users, and whack them with a big stick. I think this seems
like a reasonable job for vbscript (read: I hope). Any pointers on how
I would go about hammering a script of this nature?Appreciate any help in advance!
Advanced Disk Quotas with Vbscript
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Advanced Disk Quotas with Vbscript
Maybe this one will help:
Code: Select all
strComputer = "ServerName"
strOutputFile = "C:ScriptsDiskQuota_Logs.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.CreateTextFile(strOutputFile)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
Set colDiskQuotas = objWMIService.ExecQuery _
("Select * from Win32_DiskQuota")
Set rs = CreateObject("ADOR.RecordSet")
rs.Fields.Append "UserName", 200, 255
rs.Fields.Append "SpaceUsed", 200, 255
rs.Fields.Append "Limit", 200, 255
rs.Fields.Append "WarningLimit", 200, 255
rs.Fields.Append "Status", 200, 255
rs.Fields.Append "QuotaVolume", 200, 255
rs.Open
For each objQuota in colDiskQuotas
rs.AddNew
rs("UserName") = objQuota.User
rs("SpaceUsed") = objQuota.DiskSpaceUsed
rs("Limit") = objQuota.Limit
rs("WarningLimit") = objQuota.WarningLimit
rs("Status") = objQuota.Status
rs("QuotaVolume") = mid(objQuota.QuotaVolume, 27)
rs.Update
Next
rs.Sort = "SpaceUsed"
rs.MoveFirst
Do Until rs.EOF
strList = rs.Fields.Item("UserName") & vbTab & vbTab & _
rs.Fields.Item("SpaceUsed") & vbTab & _
rs.Fields.Item("Limit") & vbTab & _
rs.Fields.Item("WarningLimit") & vbTab & _
rs.Fields.Item("Status") & vbTab & _
rs.Fields.Item("QuotaVolume")
objTextStream.WriteLine strList
rs.MoveNext
Loop
objTextStream.close
Advanced Disk Quotas with Vbscript
PowerShell may also be an easy way to accomplish this - it has access to the same WMI objects and some built-in capability for measuring things like averages and so forth.
Advanced Disk Quotas with Vbscript
LOL... actually there's a long story. We just recently re-instated the PowerShell forums.
But I wouldn't think of it as learning two for one - PowerShell is markedly different in style and syntax.
For example...
Get-WmiObject win32_diskquote -computer server2 | measure-object spaceused -min -max -average -sum
Would show stats for all quotas on one server. Not a script - that's a single command line .
But I wouldn't think of it as learning two for one - PowerShell is markedly different in style and syntax.
For example...
Get-WmiObject win32_diskquote -computer server2 | measure-object spaceused -min -max -average -sum
Would show stats for all quotas on one server. Not a script - that's a single command line .