⚡ PowerShell 5.1+
Get Logical Disks Report
Queries Win32_LogicalDisk via WMI and reports Logical Disks in a formatted table, with an optional CSV export.
Get-LogicalDiskReport.ps1
<#
.SYNOPSIS
Reports Logical Disks on this computer via WMI (Win32_LogicalDisk).
.DESCRIPTION
Queries Win32_LogicalDisk and displays DeviceID, VolumeName, Size, FreeSpace, DriveType 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-LogicalDiskReport.ps1
.EXAMPLE
.\Get-LogicalDiskReport.ps1 -ExportPath C:\Reports\logicaldisk.csv
#>
[CmdletBinding()]
param(
[string]$ExportPath
)
$items = Get-CimInstance -ClassName Win32_LogicalDisk | Select-Object DeviceID, VolumeName, Size, FreeSpace, DriveType
if (-not $items) {
Write-Host "No Logical Disks 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
}