PowerShell WMI – Querying CD ROM informations

Hi guys,

Here is a small function I wrote to gather the CD ROM drive basic informations.
[ps]Function Get-CDROMInfo {
<#
.SYNOPSIS
Query WMI of the system to provide basic CDROM information.

.PARAMETER ComputerName
The computer name or IP of targeted computer.

.NOTES
Author: Thomas Prud’homme (Twitter: @prudhommewtf).

.LINK
https://blog.prudhomme.wtf/powershell-wmi-querying-cdrom-informations
#>
[CmdletBinding()]
Param(
[String]$ComputerName = $env:COMPUTERNAME
)
Begin {
# Win32_CDROMDrive: http://msdn.microsoft.com/en-us/library/aa394081(VS.85).aspx
$Win32_CDROMDrive = Get-WMIObject -Namespace root\CIMV2 -Class Win32_CDROMDrive -Property Drive, Manufacturer, Name -ComputerName $ComputerName
}
Process {
Write-Verbose -Message ‘CDROM gathered information:’
$Output = @()
$Win32_CDROMDrive | Sort-Object -Property Drive | ForEach-Object {
$CDROMDrive = New-Object -TypeName PSObject -Property @{
Drive = $_.Drive
Manufacturer = $_.Manufacturer
Name = $_.Name
}

$CDROMDrive.psobject.Properties | ForEach-Object {
Write-Verbose -Message "`t$($_.Name): $($_.Value)"
}

$Output += $CDROMDrive
}
}
End {
Write-Output -InputObject $Output
}
}[/ps]

See you,