PowerShell for Windows Admins

Feb 16 2010   4:11PM GMT

Disks: CD Drives

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Just to finish off our look at disks – we’ll have a quick look at CD drives

001
002
003
004
005
006
007
008
009
010
$cds = Get-WmiObject -Class Win32_CDROMDrive 
foreach ($cd in $cds){
    $cd | select Caption, Drive, MediaLoaded, Status, CompressionMethod,
    Manufacturer, MediaType,
    SCSIBus, SCSILogicalUnit, SCSIPort, SCSITargetId,
    TransferRate
    "Capabilities:"
    $cd | select -ExpandProperty CapabilityDescriptions 
    "`n"
}

In this scripts I’m putting the CD Drive information into the variable $cds.  This will be an array of WMI objects – one for each drive.  I can then use foreach to iterate through the drives.

The first select picks off a set of properties as shown – if there isn’t a CD in the drive then transfer rate will be returned as –1

The second select expands the property collection that holds the drive capability descriptions.  Doing it in two hits means I can keep the script simple

Technorati Tags: ,

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: