Feb 16 2010 4:11PM GMT
Posted by: Richard Siddaway
Disks, PowerShell v2
Disks: CD Drives
Posted by: 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: PowerShell,CD drives




