In my previous post on "Listing the file sizes of all Exchange Stores on all Exchange Servers in a Domain" I used the FSO (file system object) to get the details about the size of exchange store files and drive freespace. Somebody asked a question if there was another way to do this because in their network (as in many others) for security reasons the default admin shares (eg c$ d$) have been disabled.
One way you can go about this is to use WMI and the CIM_DataFile class, If you have Windows 2000 and your store files are above 2 GB you need to make sure you have applied the following hotfix http://support.microsoft.com/?id=820608 for this to work. But using the CIM_DataFile class is actually really easier it actually takes fewer lines of code then using FSO. For example to display the size of priv1.edb on a Exchange box once you know the location of the file its just two lines of code.
Set edbfile = GetObject("winMgmts:!\\servername\root\cimv2:CIM_DataFile.Name='e:\exchsrvr\mdbdata\priv1.edb'")
Wscript.echo "File Size: " & formatnumber(edbFile.fileSize/1073741824,2) & " GB"
To get the freespace on the drive its just as easy using the Win32_LogicalDisk WMI class eg
Set edbdrive = GetObject("winMgmts:!\\servername\root\cimv2:Win32_LogicalDisk.DeviceID='e:'")
Wscript.echo "Freespace: " & formatnumber(edbdrive.freespace/1073741824,2) & " GB"
Although i find FSO does seem a little faster its does offer a good alternative. I've created a WMI version of the Listing the file sizes of all Exchange Stores on all Exchange Servers in a Domain and posted it up here.
One way you can go about this is to use WMI and the CIM_DataFile class, If you have Windows 2000 and your store files are above 2 GB you need to make sure you have applied the following hotfix http://support.microsoft.com/?id=820608 for this to work. But using the CIM_DataFile class is actually really easier it actually takes fewer lines of code then using FSO. For example to display the size of priv1.edb on a Exchange box once you know the location of the file its just two lines of code.
Set edbfile = GetObject("winMgmts:!\\servername\root\cimv2:CIM_DataFile.Name='e:\exchsrvr\mdbdata\priv1.edb'")
Wscript.echo "File Size: " & formatnumber(edbFile.fileSize/1073741824,2) & " GB"
To get the freespace on the drive its just as easy using the Win32_LogicalDisk WMI class eg
Set edbdrive = GetObject("winMgmts:!\\servername\root\cimv2:Win32_LogicalDisk.DeviceID='e:'")
Wscript.echo "Freespace: " & formatnumber(edbdrive.freespace/1073741824,2) & " GB"
Although i find FSO does seem a little faster its does offer a good alternative. I've created a WMI version of the Listing the file sizes of all Exchange Stores on all Exchange Servers in a Domain and posted it up here.