Ian
Ian

Reputation: 4467

Win32_LogicalDisk Access Property Always Unknown in PowerShell

I'm using a simple script to check the status of CD/DVD drives on a machine. I want to be able to tell if a certain drive is writable. I have the 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 will show the drive letter of the CD/DVD drive on my machine, but the Access parameter always comes back as 0 (Unknown) even though I have a writable CD inserted into the drive. I have tried formatting the CD to be used the same as a USB device (as opposed to a music CD) so that I can open it to browse the file structure (there are no files), but this doesn't change anything.

Isn't the Access property supposed to give me 2 or 3 or 4 instead of 0?

EDIT:

I tried inserting a playable DVD and CD. DVD doesn't read, the CD works though. I was also able to burn a CD and play it on a normal CD player. Throughout this process I ran the command given by Jan below and got the 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 anything is inserted into drive D, or what type of disk it is, this is the output. I'm suspicious that my drive is busted since it wouldn't read a video DVD, but I dunno. This was a refurbished desktop. Are there any more reliable ways to check for a writeable CD using PS?

Upvotes: 0

Views: 1073

Answers (2)

Ian
Ian

Reputation: 4467

I eventually found that my CD/DVD drive was on its way out. It wouldn't burn DVD's and eventually stopped reading or burning anything. I figure this has something to do with my troubles.

Upvotes: 0

Jan Chrbolka
Jan Chrbolka

Reputation: 4464

Access field in a CD/DVD drive will be blank, if there is no media in the drive. Once you insert a disk into the drive, you can read the MediaType, Access fields and lots of other info.

To find the Capabilities of a CD/DVD you can use Win32_CDROMDrive MediaType property.

PS > Get-WmiObject Win32_CDROMDrive | Select Caption, Drive, MediaType

Caption                                          Drive                                            MediaType                                       
-------                                          -----                                            ---------                                       
hp DVD A  DH16ABLH                               G:                                               DVD Writer

Reference - Checking if a CD/DVD drive is a Writer or just a Cd-Rom using WMI

Upvotes: 1

Related Questions