Is this possible?
My first guess would be something like:
C:> Get-WmiObject Win32_CDROMDrive
But when I tried this, it only tells me Caption
, Drive
, Manufacturer
,VolumeName
No information on whether or not there is a CD in the disc drive.
Microsoft Windows usersOpen System Information. In the System Information window, click the + symbol next to Components. If you see "CD-ROM," click it once to display the CD-ROM in the left window.
For a list of the Windows PowerShell drives in your Windows PowerShell session, use the Get-PSDrive cmdlet. Although the drives in the display vary with the drives on your system, the listing will look similar to the output of the Get-PSDrive command shown above.
In the Run dialog box, type devmgmt. msc then press the Enter key. In the Device Manager window, expand DVD/CD-ROM drives. Verify that the optical drive is listed.
The Get-PSDrive cmdlet gets the drives in the current session. You can get a particular drive or all drives in the session. This cmdlet gets the following types of drives: Windows logical drives on the computer, including drives mapped to network shares.
You can get this information by
(Get-WMIObject -Class Win32_CDROMDrive -Property *).MediaLoaded
You can see what properties are available for that WMI class by
Get-WMIObject -Class Win32_CDROMDrive -Property * | Get-Member
and more detailed documentation from
Get-WMIHelp -Class Win32_CDROMDrive
In general, you will find that liberal use of the Get-Help
, Get-Member
, Get-Command
, and Get-WMIHelp
cmdlets will provide you with a great deal of information, and possibly eliminate the need to ask questions like this here and wait for an answer that may or may not come.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With