Get-sqmDiskInfoByDriveLetter Configuration

Returns detailed disk information for a single drive letter: total/free space, free percent, disk serial number, VM detection, shared-disk detection, and the minimum extension size needed to reach the configured free-space threshold. Copies result to clipboard by default.

Execution Flow

START Read DiskFreeSpaceThresholdPct from Get-sqmConfig (default 10) Get-Partition -DriveLetter $DriveLetter → $partition Get-Disk -Number $partition.DiskNumber → $disk Get-CimInstance Win32_LogicalDisk → TotalSize, FreeSpace Calculate TotalGB, FreeGB, FreePercent FreePercent < ThresholdPct? ExtendNeededGB = ceil((thr×Tot-Free) ÷(1-thr)) YES Get-sqmMachineType → IsVM / MachineType Get-Partition -DiskNumber → other drive letters → IsPartitionedDisk Build result PSCustomObject -NoClipboard? skip YES $result | ConvertTo-Json | Set-Clipboard Return $result DONE

Synopsis

Combines Get-Partition, Get-Disk, and Get-CimInstance Win32_LogicalDisk to provide a complete picture of a single drive. The free-space threshold is read from Get-sqmConfig -Key 'DiskFreeSpaceThresholdPct'. When free space falls below the threshold, ExtendNeededGB is calculated to determine the minimum disk extension required. Shared-disk detection queries all partitions on the same physical disk for other drive letters.

ExtendNeededGB = Ceil( (threshold × TotalGB − FreeGB) ÷ (1 − threshold) )
# threshold = DiskFreeSpaceThresholdPct / 100

Syntax

Get-sqmDiskInfoByDriveLetter
    -DriveLetter <String>    # single letter A-Z
    [-NoClipboard]
    [-EnableException]

Parameters

ParameterTypeDefaultDescription
-DriveLetterStringRequiredSingle drive letter (A–Z) to inspect. Do not include colon or backslash.
-NoClipboardSwitchfalseSuppress copying the result to the clipboard.
-EnableExceptionSwitchfalseThrow terminating exceptions.

Return Value

PropertyDescription
DriveLetterDrive letter inspected.
DiskNumberPhysical disk number from Get-Partition.
TotalGBTotal volume capacity in GB (rounded to 2 decimal places).
FreeGBFree space in GB (rounded to 2 decimal places).
FreePercentFree space as percentage of TotalGB.
ThresholdPctConfigured threshold from DiskFreeSpaceThresholdPct.
ExtendNeededGBMinimum extension size in GB to reach threshold. 0 when free space is sufficient.
SerialNumberPhysical disk serial number from Get-Disk.
IsVMBoolean — true if running in a virtual machine (via Get-sqmMachineType).
MachineTypePhysical / HyperV / VMware / etc.
IsPartitionedDiskBoolean — true if this physical disk contains other drive letters.
SharedWithList of other drive letters on the same physical disk.

Examples

# Get info for drive D:
Get-sqmDiskInfoByDriveLetter -DriveLetter "D"

# Suppress clipboard copy (e.g. in automated scripts)
Get-sqmDiskInfoByDriveLetter -DriveLetter "E" -NoClipboard

# Check if extension is needed
$info = Get-sqmDiskInfoByDriveLetter -DriveLetter "D"
if ($info.ExtendNeededGB -gt 0) {
    Write-Host "Extend D: by at least $($info.ExtendNeededGB) GB"
}