Ashish's Note

Over the past few years, I learnt a lot and get fond of Microsoft Technlogy. From The basics of Active Directory to the high end troubleshooting and disaster recovery, to the VPN configuration, Its being a good time for me as I got lots of opportunities to learn and grow.

In 2004, I got hired by "Microsoft" as a full time employee in its GTSC located in Bangalore. I experienced hardcore troubleshooting on real time issues as a big challange and very very intersting, which gave me vibrant knowledge of Operating System Troubleshooting, Active Directory, Clustering, Performance, Disks, Terminal Server, Printing, STOP Codes and BSOD screens.

My Fantastic past experience on HP/MSCS cluster, Server Hardware and System Administration, boosted my skills to take charge of customer's problem and make me to deal with the issues till the resolution.


Today working with Perot Systems, I am using this Blog to contribute my knowledge to the society and to make every individual who need directives to grow in IT field.

Lets post your views and questions you have, hit my brain to let it mentor the best possible IT solutions and career options.

Yours,

Ashish Sharma.

Thursday, May 31, 2007

Script: Retrieving Free Disk Space

Flash Tip: Illustrated Script - Retrieving Free Disk Space

Q: How do I retrieve free disk space from drive C?

A: The script below illustrates the importance of Automation objects within Microsoft Visual Basic Scripting Edition (VBScript). If you have been having problems with users filling up drive C on their computers, you can use the three-line script below to find out how much free disk space is available on drive C of a computer.

Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
Wscript.Echo objLogicalDisk.FreeSpace

You now have a custom solution for identifying the computers running low on disk space, a solution developed using very little VBScript code. Instead, the script:
1.
Connects to Windows Management Instrumentation (WMI), an Automation object, by using the VBScript GetObject method.
2.
Uses the WMI Get method to retrieve information about drive C.
3.
Uses the Windows Script Host (WSH) Echo method to report the amount of free disk space on drive C.
The primary purpose of the little VBScript code that is used is to glue together the functionality of WMI and WSH.
Based on “VBScript Primer,” from the book Microsoft Windows 2000 Scripting Guide by Microsoft Corporation. Reprinted by permission of Microsoft Press. All rights reserved. For more information, go to http://www.microsoft.com/mspress/books/toc/6417.aspx.

0 comments: