473,396 Members | 1,725 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

script to get the free disk space from all the servers

Hi All, I am new to the scritping world but did my best in colloating some information and wirting a script to get the free disk space from all the servers.. The only issue is for the servers on which i do not have access, the script is showing the same data of the previous server.in short "On Error Resume Next" is not working :-(

Expand|Select|Wrap|Line Numbers
  1. On Error Resume Next
  2.  
  3. Set objFSO = CreateObject("Scripting.FileSystemObject")
  4. Set objTextFile = objFSO.OpenTextFile("C:\Documents and Settings\e580631\Desktop\Servers.txt")
  5. Set objWMIService = GetObject("winmgmts:" _
  6.     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  7.  
  8. Set colItems = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
  9.  
  10. Do Until objTextFile.AtEndOfStream
  11. strComputer = objTextFile.ReadLine
  12.  
  13. Wscript.Echo "ServerName : " & strComputer
  14.  
  15. For Each objItem in colItems
  16. Wscript.Echo "DeviceID: "& VbTab & ObjItem.Name
  17. Wscript.Echo "Total DiskSpace(IN GB): "& VbTab & Round(objItem.Size /1073741824,2)
  18. Wscript.Echo "Free DiskSpace(IN GB): "& VbTab & Round(objItem.FreeSpace / 1073741824)
  19. Wscript.Echo "Percentage Free: "& VbTab & Round((objItem.FreeSpace / objItem.Size) * 1000)/10
  20. Next
  21. Loop
  22. WSCript.Quit
Kindly Assist.
Mar 25 '12 #1
1 2541
ADezii
8,834 Expert 8TB
You may have to Reset/Assign Variable Values for each iteration of the Loop (Each objItem In colItems), as in:
Expand|Select|Wrap|Line Numbers
  1. Dim strDeviceID As String
  2. Dim varTotalDiskSpace As Variant
  3. Dim varFreeDiskSpace As Variant
  4. Dim varPercentageFree As Variant
Expand|Select|Wrap|Line Numbers
  1. For Each objItem In colItems
  2.   strDeviceID = ""
  3.   varTotalDiskSpace = Null
  4.   varFreeDiskSpace = Null
  5.   varPercentageFree = Null
  6.  
  7.   strDeviceID = objItem.Name
  8.   varTotalDiskSpace = Round(objItem.Size / 1073741824, 2)
  9.   varFreeDiskSpace = Round(objItem.FreeSpace / 1073741824)
  10.   varPercentageFree = Round((objItem.FreeSpace / objItem.Size) * 1000) / 10
  11.  
  12.   Wscript.Echo "DeviceID: " & vbTab & strDeviceID
  13.   Wscript.Echo "Total DiskSpace(IN GB): " & vbTab & varTotalDiskSpace
  14.   Wscript.Echo "Free DiskSpace(IN GB): " & vbTab & varFreeDiskSpace
  15.   Wscript.Echo "Percentage Free: " & vbTab & varPercentageFree
  16. Next
Mar 25 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: O.Gir | last post by:
Hi all, can't manage to do it ..... was so easy under solaris .... anybody knows how to get free disk space on remote disks ??? (with both local and remote *$#@%§&* machines running *$#@%§&*...
3
by: Jas Shultz | last post by:
I'm using Win2K3 Enterprise edition with the latest .NET framework installed. I have this problem with getting "out of disk space" errors. It doesn't happen all the time but it does happen. When...
2
by: Sagar Choudhary | last post by:
Is there any exception related to disk space ? If not how else can we check the availability of the disk space in a c++ program. I know ostream helps a bit. When we try to open a file when there's...
6
by: Anthony Robinson | last post by:
I am trying to instal FixPak 4 for V8 on XP. I kept getting an error. During the install, I kept getting the "low disk space on c:" message. My C; drive has 1.4 GB of free space. I can't believe...
5
by: Yasaswi Pulavarti | last post by:
does a command like, db2 drop table tabschema.tabname when run from the Aix prompt reclaim the disk space? Are there any other options? How can we make sure the disk space is reclaimed? Thanks,...
3
by: A P | last post by:
Hi, I am loosing disk space and wanting to install .Net Framework on my W2KSP4 Server. I only have 400MB available, is this enough for me to install .Net Framework? Me
6
by: Dan | last post by:
Hi - I am very new to VB.NET, making the transition from VB6. I converted one of my apps using the wizard, and notice it's running considerably slower than the VB6 version. I'm thinking it may...
5
by: mostro713 | last post by:
Hello all, I would like to write a script in Python to email me when disk space gets below a certain value. My first question (I'm sure of many) is how do get this output into a dictionary or...
2
by: asmpic | last post by:
Hi, I stumbled upon a script on the internet that monitors disk space and if it reaches a certain percentage being full it send an email. However, the problem I encountered was that one of the file...
0
by: DannielHS | last post by:
- Windows created the low disk space warning to alert computer users when their hard drive is running low on available disk space. Then you will see on a fairly regular basis as your hard drive fills...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.