The essentials
Quick reference
One focused task per row. Jump to the related section for complete, working examples.
| Use | Syntax | Examples |
|---|---|---|
| List physical disks | Get-PhysicalDisk | Sort-Object FriendlyName | View examples |
| List disks | Get-Disk | Sort-Object Number | View examples |
| Inspect one disk | Get-Disk -Number 2 |
Format-List Number, FriendlyName, SerialNumber, UniqueId, BusType, Size, PartitionStyle | View examples |
| List disk partitions | Get-Partition -DiskNumber 2 | View examples |
| List volumes | Get-Volume | Sort-Object DriveLetter, FileSystemLabel | View examples |
| Resolve a drive letter | Get-Partition -DriveLetter D | Get-Volume | View examples |
| Inspect resize range | Get-PartitionSupportedSize -DriveLetter D | View examples |
| Resize a partition | Resize-Partition -DriveLetter D -Size 500GB | View examples |
| Preview taking a disk offline | Set-Disk -Number 2 -IsOffline $true -WhatIf | View examples |
| Preview assigning a letter | Set-Partition -DiskNumber 2 -PartitionNumber 1 `
-NewDriveLetter R -WhatIf | View examples |
| Initialize a raw disk | Initialize-Disk -Number 2 -PartitionStyle GPT | View examples |
| Create a maximum partition | New-Partition -DiskNumber 2 -UseMaximumSize `
-AssignDriveLetter | View examples |
| Format a volume | Format-Volume -DriveLetter R -FileSystem NTFS `
-NewFileSystemLabel 'Archive' -Confirm | View examples |
| Scan a volume | Repair-Volume -DriveLetter D -Scan | View examples |
Windows storage cmdlets expose physical disks, partition tables, partitions, and formatted volumes as different objects. Resolve devices by number, unique ID, bus, size, and state before changes; capture current layout; inspect supported sizes; and require backups before initialization, formatting, or resizing.
Step by step
Detailed examples
Identify hardware with more than a disk number
Disk numbers can change with boot or attachment order. Record Number, UniqueId, serial, bus, model, size, partition style, boot/system flags, and location where available. Get-PhysicalDisk and Get-Disk describe related but different management layers.
Get-Disk | Select-Object Number, FriendlyName, SerialNumber, UniqueId, BusType, Size, PartitionStyle, IsBoot, IsSystem, OperationalStatus
Get-PhysicalDisk | Select-Object FriendlyName, SerialNumber, MediaType, HealthStatus, OperationalStatus, Size Map disk, partition, and volume layers
A disk contains partitions; a partition may expose a volume; a volume contains a filesystem and mount points. Not every partition is user data. Preserve EFI, recovery, reserved, and boot partitions, and never infer purpose solely from size.
$diskNumber = 2
Get-Disk -Number $diskNumber | Format-List *
Get-Partition -DiskNumber $diskNumber | ForEach-Object {
$_
$_ | Get-Volume -ErrorAction SilentlyContinue
} Check supported range, health, and backups
Get-PartitionSupportedSize computes current minimum and maximum. Resize-Partition can grow or shrink the partition and filesystem but lacks WhatIf, making the final call immediately stateful. Suspend encryption as required, check application and cluster constraints, and keep a tested backup.
$current = Get-Partition -DriveLetter D
$supported = Get-PartitionSupportedSize -DriveLetter D
[pscustomobject]@{ Current = $current.Size; Minimum = $supported.SizeMin; Maximum = $supported.SizeMax; Proposed = 500GB } | Format-List Preview reversible state and letter changes
Taking a disk offline affects every contained volume. Drive-letter changes break paths, services, tasks, shares, and applications. Resolve the exact disk and partition first, use WhatIf where exposed, notify consumers, and verify mount-point alternatives.
Get-Disk -Number 2 | Format-List Number, UniqueId, IsOffline, IsReadOnly
Set-Disk -Number 2 -IsOffline $true -WhatIf
Get-Partition -DiskNumber 2 -PartitionNumber 1
Set-Partition -DiskNumber 2 -PartitionNumber 1 -NewDriveLetter R -WhatIf Treat initialization and formatting as destructive
Initialize-Disk writes a partition table; New-Partition changes layout; Format-Volume creates a filesystem and destroys access to prior data. Confirm the disk is truly RAW and unused using independent inventory, disconnect similar devices when practical, and do not pipeline discovery into these commands.
$candidate = Get-Disk -Number 2
$candidate | Format-List Number, UniqueId, SerialNumber, BusType, Size, PartitionStyle, OperationalStatus
if ($candidate.PartitionStyle -ne 'RAW') { throw 'Disk is not RAW; stop.' }
# Run each approved state-changing command separately only after independent verification. Correlate filesystem and device health
Volume health, physical-disk health, event logs, and vendor telemetry answer different questions. Repair-Volume scan detects filesystem issues, while repair modes may require downtime and do not fix failing hardware. Back up readable data before repair when failure is suspected.
Get-Volume -DriveLetter D | Format-List DriveLetter, FileSystem, HealthStatus, OperationalStatus, Size, SizeRemaining
Get-PhysicalDisk | Select-Object FriendlyName, HealthStatus, OperationalStatus
Repair-Volume -DriveLetter D -Scan Sources and further reading
References
Authoritative documentation used to verify and expand this cheat sheet.
Help us improve
Found a typo or missing example?
Tell us what would make this cheat sheet clearer, more complete, or more useful.



