Is there a script I can use to detect the amount of disk space left for our employees?

techin4
techin4 used Ask the Experts™
on
Hi,
I was wondering if theres a script that would show me how much disk space is left in our employee's computer. We currently have a domain with Windows Server 2003 installed.

Thank You.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007

Commented:
So is that disk space on the employees computers (if so, we need the OS on the desktop - not the server) or is that disk space on the server reserved for each employee - and if so, are you talking about quota space (if so, which quota product)?
Top Expert 2007

Commented:
Here's one script that will show disk usage:
ref: http://www.computerperformance.co.uk/vbscript/wmi_disks.htm
 
' LogicalDisk.vbs
' Sample VBScript to interrogate a Logical disk with WMI
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.8 - November 2005
' -------------------------------------------------------------' 
Option Explicit
Dim objWMIService, objItem, colItems, strComputer
 
On Error Resume Next
strComputer = "."
 
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk")
 
For Each objItem in colItems
Wscript.Echo "Computer: " & objItem.SystemName & VbCr & _ 
" ==================================" & VbCr & _ 
"Drive Letter: " & objItem.Name & vbCr & _ 
"Description: " & objItem.Description & vbCr & _ 
"Volume Name: " & objItem.VolumeName & vbCr & _ 
"Drive Type: " & objItem.DriveType & vbCr & _ 
"Media Type: " & objItem.MediaType & vbCr & _ 
"VolumeSerialNumber: " & objItem.VolumeSerialNumber & vbCr & _
"Size: " & Int(objItem.Size /1073741824) & " GB" & vbCr & _ 
"Free Space: " & Int(objItem.FreeSpace /1073741824) & _
" GB" & vbCr & _ 
"Quotas Disabled: " & objItem.QuotasDisabled & vbCr & _ 
"Supports DiskQuotas: " & objItem.SupportsDiskQuotas & vbCr & _
"Supports FileBasedCompression: " & _
objItem.SupportsFileBasedCompression & vbCr & _ 
"Compressed: " & objItem.Compressed & vbCr & _ 
"" 
Next
 
WSCript.Quit
 
' End of Sample DiskDrive VBScript

Open in new window

Commented:
Hello,

you can use WMI to get information on remote computer. Below is a sample script that return freespace on your computer, from here :http://www.computerperformance.co.uk/vbscript/wmi_disks.htm

You just need to replace the strComputer variable with the name / Ip adress of the machine you want to check.

You can alos use this as a function, and for example get all computer in Active Directory and use this function on them.

regards,
Option Explicit
Dim objWMIService, objItem, colItems, strComputer
 
On Error Resume Next
strComputer = "."
 
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk")
 
For Each objItem in colItems
Wscript.Echo "Computer: " & objItem.SystemName & VbCr & _ 
" ==================================" & VbCr & _ 
"Drive Letter: " & objItem.Name & vbCr & _ 
"Size: " & Int(objItem.Size /1073741824) & " GB" & vbCr & _ 
"Free Space: " & Int(objItem.FreeSpace /1073741824) & _
" GB" & vbCr & _ 
Next
 
WSCript.Quit
 
' End of Sample DiskDrive VBScript

Open in new window

Acronis in Gartner 2019 MQ for datacenter backup

It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.

Most Valuable Expert 2011
Top Expert 2011

Commented:
Just for giggles.....
Start>run>cmd
fsutil volume diskfree c:
Just in case you are trying to do this across multiple machines......
Can pipe it to a public share, in a text file......Save it as FreeSpace.bat
PSExec can run it against all PC's in the domain, or during your login script......
Output looks like this....

Laptop was scanned on Wed 07/22/2009 and has the following Drive Space usage:
Total # of free bytes        : 82378997760
Total # of bytes             : 120023252992
Total # of avail free bytes  : 82378997760
 
 

@echo off 
echo %computername% was scanned on %date% and has the following Drive Space usage:
 >\\Server\share\FreeSpace.txt
fsutil volume diskfree c: >\\Server\share\FreeSpace.txt
echo. >\\Server\share\FreeSpace.txt

Open in new window

Author

Commented:
Hi,

I tired running that script and it works fine locally but when I try to add a different username,
nothing comes up.
Any suggestions?
Thank You.
Top Expert 2007

Commented:
Different username?  Should be different 'computer' name, no?
Most Valuable Expert 2011
Top Expert 2011

Commented:
Which script?
 

Author

Commented:
The one from pilozite
sirbounty, I mean computername not username.
Am I suppose to run this on the server or can I run this on any local machine?  Thanks
Top Expert 2007

Commented:
You can run it from any machine.
If strcomputer = "." (period) then it's going to return results for the local machine.
You can add a remote computer name there instead - either way will work:

strComputer = "ServerA"

Commented:
Hello,

Did you succeed using this script on a remote machine ?

Author

Commented:
Hello,

I was not able to run it on a remote machine.
Top Expert 2007

Commented:
Can you elaborate?

Author

Commented:
I ran the script on my machine trying to access other machines on our network but nothing was returned from the script.
Top Expert 2007
Commented:
techin4 - please try this with one or two test machines first.
The following adjustment allows for an array of computers.  I'd say just add 2-3 that you know you have admin access to remotely.
Please post the results...
Option Explicit
Dim strComputer, arrComputers, objItem
 
arrComputers = Array ("Computer1", "Computer15", "Computer99")
 
For Each strComputer in arrComputers
  Dim objWMI Service: Set objWMIService = GetObject ("winmgmts:\\" & strComputer & "\root\cimv2")
  Dim colItems : Set colItems = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
 
  For Each objItem in colItems
    Wscript.Echo "Computer: " & objItem.SystemName & VbCr & " ==================================" & VbCr & _ 
      "Drive Letter: " & objItem.Name & vbCr & "Description: " & objItem.Description & vbCr & _ 
      "Volume Name: " & objItem.VolumeName & vbCr & "Drive Type: " & objItem.DriveType & vbCr & _ 
      "Media Type: " & objItem.MediaType & vbCr & "VolumeSerialNumber: " & objItem.VolumeSerialNumber & vbCr & _
      "Size: " & Int(objItem.Size /1073741824) & " GB" & vbCr & "Free Space: " & Int(objItem.FreeSpace /1073741824) & _
      " GB" & vbCr & "Quotas Disabled: " & objItem.QuotasDisabled & vbCr & _ 
      "Supports DiskQuotas: " & objItem.SupportsDiskQuotas & vbCr & "Supports FileBasedCompression: " & _
      objItem.SupportsFileBasedCompression & vbCr & "Compressed: " & objItem.Compressed & vbCr & "" 
  Next ' For Each objItem in colItems
Next ' For Each strComputer in arrComputers
WSCript.Quit

Open in new window

Top Expert 2007

Commented:
I'd say the onus is on you to supply updates...?
When an experts comment is the last post made, it's up to the asker to post a status update to that effect.
Had you stayed more involved in your question, this might have gotten solved and thus, my time wouldn't have been wasted...
Top Expert 2007

Commented:
I know that http:#25199811 works - I use it myself on more than 100 devices.
I feel if the author had stayed involved, this could have been sorted on their end as well, but I never heard back until I got the delete request...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial