Sign in to follow this  
Followers 0
digitalworld

Is there a way to get disk size if the drive is not formatted?

6 posts in this topic

Is there a way to get disk size if the drive is not formatted? Only thing i know is the disk id number from the winodws disk management?

Thanks

Share this post


Link to post
Share on other sites



Is there a way to get disk size if the drive is not formatted? Only thing i know is the disk id number from the winodws disk management?

Thanks

you can use the wmi i guess

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.ExecQuery ("Select * from Win32_DiskDrive")
For $objItem In $colItems
    $size = $objItem.Size
Next

MsgBox(0, "DriveSize", $size)

[font="Comic Sans Ms"][center]Powered by AutoIt3http://www.wik-eric.de/zips/Synchro2.2.2-4free.zip[/center][/font]

Share this post


Link to post
Share on other sites

Made the script a little more user friendly.

$strComputer = InputBox("Computer Name", "Please enter the computer name" & @Lf & "you wish to get drive size from.")
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.ExecQuery ("Select * from Win32_DiskDrive")
For $objItem In $colItems
    $size = $objItem.Size
Next
$size = $size / 1073741824
$capacity = StringFormat("%.2f", $size)
MsgBox(0, "DriveSize", $capacity & "GB")

Share this post


Link to post
Share on other sites

Could someone help me turn $colDisks into an array?

$strComputer = InputBox("Computer Name", "Please enter the computer name" & @Lf & "you wish to get drive size from.")
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colDisks = $objWMIService.ExecQuery ("Select * from Win32_DiskDrive")

For $objDisk In $colDisks
    $device = StringTrimLeft($objDisk.DeviceID, 4)  
    $size = $objDisk.Size / 1073741824
    $capacity = StringFormat("%.2f", $size) 
    MsgBox(0, "", "DeviceID: " & $device & @LF & "Disk Size: " & $capacity & "GB")
    If @error <> 0 Then ExitLoop
Next

Share this post


Link to post
Share on other sites

the only way is to create 2 or more arrays like this !?! Maybe there is another trick :">

#include <Array.au3>

$strComputer = InputBox("Computer Name", "Please enter the computer name" & @Lf & "you wish to get drive size from.")

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")

$colDisks = $objWMIService.ExecQuery ("Select * from Win32_DiskDrive")

$i=1

dim $Sizearray[1]

Dim $Disk[1]

For $objDisk In $colDisks

$device = StringTrimLeft($objDisk.DeviceID, 4)

$size = $objDisk.Size / 1073741824

$capacity = StringFormat("%.2f", $size)

_ArrayAdd($Disk,$device)

_ArrayAdd($Sizearray,$size)

MsgBox(0, "", "DeviceID: " & $device & @LF & "Disk Size: " & $capacity & "GB")

$i=$i+1

ReDim $Disk[uBound($Disk+$i)]

Redim $Sizearray[uBound($Sizearray+$i)]

If @error <> 0 Then ExitLoop

Next

_ArrayDisplay($Disk,"Device")

_ArrayDisplay($Sizearray,"Size")

Share this post


Link to post
Share on other sites

you can use the wmi i guess

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.ExecQuery ("Select * from Win32_DiskDrive")
For $objItem In $colItems
    $size = $objItem.Size
Next

MsgBox(0, "DriveSize", $size)

Thanks rudika..i get the following error. please see the attached screenshot

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0