Change a Drive Letter with PowerShell (Set-Partition)

Reassign a volume's drive letter with the Storage module instead of clicking through Disk Management.

WindowsFilesdiskadminpowershellMedium risk
Run Get-Partition -DriveLetter D | Set-Partition -NewDriveLetter E in an admin PowerShell.

01Command

Command
$ Get-Partition | Format-Table DriveLetter, DiskNumber, PartitionNumber, Size
Get-Partition -DriveLetter D | Set-Partition -NewDriveLetter E

02What 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

RiskMedium risk
RequirementsElevated (admin) PowerShell; the new letter must not be in use; don't change the letter of the Windows system partition.
!Warning: Programs and shortcuts pointing at the old letter (installed apps, backup jobs, pagefile on non-system drives) will break until updated; never change the letter of the Windows/EFI system partition.

04Undo

Undo
$ Get-Partition -DriveLetter E | Set-Partition -NewDriveLetter D

05Sources

  • Set-Partition
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: 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