⚡ PowerShell 5.1+
Get Physical Disk Drives Report
Queries Win32_DiskDrive via WMI and reports Physical Disk Drives in a formatted table, with an optional CSV export.
Get-DiskDriveReport.ps1
<#
.SYNOPSIS
Reports Physical Disk Drives on this computer via WMI (Win32_DiskDrive).
.DESCRIPTION
Queries Win32_DiskDrive and displays Model, Size, InterfaceType, Status for each item found.
Use -ExportPath to also save the results to a CSV file.
.PARAMETER ExportPath
Optional path to a .csv file to write the results to.
.EXAMPLE
.\Get-DiskDriveReport.ps1
.EXAMPLE
.\Get-DiskDriveReport.ps1 -ExportPath C:\Reports\diskdrive.csv
#>
[CmdletBinding()]
param(
[string]$ExportPath
)
$items = Get-CimInstance -ClassName Win32_DiskDrive | Select-Object Model, Size, InterfaceType, Status
if (-not $items) {
Write-Host "No Physical Disk Drives found." -ForegroundColor Yellow
return
}
$items | Format-Table -AutoSize
if ($ExportPath) {
$items | Export-Csv -Path $ExportPath -NoTypeInformation -Encoding UTF8
Write-Host "`nExported to $ExportPath" -ForegroundColor Cyan
}