cd drive - Win32_LogicalDisk Access Property Always Unknown in PowerShell -
i'm using simple script check status of cd/dvd drives on machine. want able tell if drive writable. have following test code:
$script_obj = new-object -comobject wscript.shell $drives = @(get-wmiobject win32_logicaldisk -filter 'drivetype=5') $script_obj.popup($drives[0].deviceid + " " + $drives[0].access)
this show drive letter of cd/dvd drive on machine, access parameter comes 0 (unknown) though have writable cd inserted drive. have tried formatting cd used same usb device (as opposed music cd) can open browse file structure (there no files), doesn't change anything.
isn't access property supposed give me 2 or 3 or 4 instead of 0?
edit:
i tried inserting playable dvd , cd. dvd doesn't read, cd works though. able burn cd , play on normal cd player. throughout process ran command given jan below , got same output every time:
ps c:\users\ian> get-wmiobject win32_cdromdrive | select caption, drive, mediatype, access caption drive mediatype access ------- ----- --------- ------ hp cddvdw sh-216al d: dvd writer
it doesn't matter whether or not inserted drive d, or type of disk is, output. i'm suspicious drive busted since wouldn't read video dvd, dunno. refurbished desktop. there more reliable ways check writeable cd using ps?
access
field in cd/dvd drive blank, if there no media in drive. once insert disk drive, can read mediatype
, access
fields , lots of other info.
to find capabilities of cd/dvd can use win32_cdromdrive
mediatype
property.
ps > get-wmiobject win32_cdromdrive | select caption, drive, mediatype caption drive mediatype ------- ----- --------- hp dvd dh16ablh g: dvd writer
reference - checking if cd/dvd drive writer or cd-rom using wmi
Comments
Post a Comment