Change a Drive Letter with PowerShell (Set-Partition)
Reassign a volume's drive letter with the Storage module instead of clicking through Disk Management.
01Command
$ Get-Partition | Format-Table DriveLetter, DiskNumber, PartitionNumber, Size
Get-Partition -DriveLetter D | Set-Partition -NewDriveLetter E02What it does
Windows assigns letters in order it discovers disks, so plugging in a USB drive can shift a mapped drive and break shortcuts. Set-Partition -NewDriveLetter renames the letter directly; the partition and its data are untouched, only the path changes. The same job can be done interactively with diskpart (select volume → assign letter=E) or the Disk Management GUI, but the PowerShell form is scriptable.
03Risk
04Undo
$ Get-Partition -DriveLetter E | Set-Partition -NewDriveLetter D05Sources
- Set-PartitionEvidence: Set-Partition -NewDriveLetter assigns or changes a partition's drive letter in the Storage module.
Last verified: 2026-09-18 · Category: Files & Folders
06Related solutions
One PowerShell line showing drive letters, labels, filesystems and free space for every volume.
Read-only PowerShell view of each disk's model, bus type, health and partition style.
Diagnose NTFS file system errors and bad sectors on any volume — including the system drive while Windows is running — before committing to a repair.