Free disk space from volume mount point.
Hello,
My assignment is to create a script that will get report all disks, sizes
and free space from all our domain member servers.
Now I'm trying to find a way to get the free (or used) disk space
information in a volume mount point disk
I have the script ready and it's working like a charm. The only thing it
doesn't do is report the disks who do not have a drive letter assigned but
are mounted inside another disk instead.
We have a lot of servers who have their volumes mounted and I can't use a
3rd party app.
The only thing I can find for mountpoints is a default example app which I
modified to just report the volume mount points and not ALL disks drives.
Unfortunately "Win32_MountPoint" does not support the property "FreeSpace"
This is all i have for now:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery _
("SELECT * FROM Win32_MountPoint")
For Each objItem In colItems
DirL =
Mid(objItem.Directory,Instr(objItem.Directory,"=")+1,len(objItem.Directory))
If len(DirL) > 6 then
WScript.Echo "Directory: " & objItem.Directory
WScript.Echo "Volume: " & objItem.Volume
end if
Next
Thanks in advance,
Albert.
Re: Free disk space from volume mount point.
Never mind I found it myself.
For anyone who likes to know how, I used Win32_Volume instead of
Win32_LogicalDisk.
Here's a code snipet:
Set objDISKWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colDiskItems = objDISKWMIService.ExecQuery _
("Select * from Win32_Volume")
For Each objDiskItem in colDiskItems
if objDiskItem.DriveType = 3 then
strDiskSize = round(objDiskItem.Capacity /1073741824,3)
strDisk = strDisk & vbCr & _
"Drive Letter: " & objDiskItem.Name & vbCr & _
"Device ID : " & objDiskItem.DeviceID & vbCr & _
"Disk Size : " & strDiskSize & vbCr & "Free Space : " _
& Int(objDiskItem.FreeSpace /1048576) & " MB" & vbCr & _
" ========================="
If LogPositivesOnly then
If strDiskSize > 0 then MyFile.WriteLine StrComputer & ";" &
objDiskItem.Name & ";" & objDiskItem.Label & ";" & strDiskSize & ";" &
round(objDiskItem.FreeSpace/1073741824,3) & ";" & objDiskItem.FileSystem &
";" & objDiskItem.DriveType
Else
MyFile.WriteLine StrComputer & ";" &
objDiskItem.Name & ";" & objDiskItem.Label & ";" & strDiskSize & ";" &
round(objDiskItem.FreeSpace/1073741824,3) & ";" & objDiskItem.FileSystem &
";" & objDiskItem.DriveType
End if
end if
thanks for looking.
Albert.
"Albert Kikkert" <a.kikkert@gmail.com> wrote in message
news:%23fsXq0PiIHA.4684@TK2MSFTNGP06.phx.gbl...
> Hello,
>
> My assignment is to create a script that will get report all disks, sizes
> and free space from all our domain member servers.
> Now I'm trying to find a way to get the free (or used) disk space
> information in a volume mount point disk
>
> I have the script ready and it's working like a charm. The only thing it
> doesn't do is report the disks who do not have a drive letter assigned but
> are mounted inside another disk instead.
>
> We have a lot of servers who have their volumes mounted and I can't use a
> 3rd party app.
> The only thing I can find for mountpoints is a default example app which I
> modified to just report the volume mount points and not ALL disks drives.
> Unfortunately "Win32_MountPoint" does not support the property "FreeSpace"
>
> This is all i have for now:
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
> Set colItems = objWMIService.ExecQuery _
> ("SELECT * FROM Win32_MountPoint")
> For Each objItem In colItems
> DirL =
> Mid(objItem.Directory,Instr(objItem.Directory,"=")+1,len(objItem.Directory))
> If len(DirL) > 6 then
> WScript.Echo "Directory: " & objItem.Directory
> WScript.Echo "Volume: " & objItem.Volume
> end if
> Next
>
> Thanks in advance,
>
> Albert.
>