Skip to content

Instantly share code, notes, and snippets.

@Jawabiscuit
Last active December 28, 2021 16:37
Show Gist options
  • Save Jawabiscuit/f0b3952f558470c2034bb70e40933e29 to your computer and use it in GitHub Desktop.
Save Jawabiscuit/f0b3952f558470c2034bb70e40933e29 to your computer and use it in GitHub Desktop.
Change drive letters on Windows
# Change drive letters and labels on Windows using powershell
# On a new install, Windows maps drives somewhat randomly
# Details: https://devblogs.microsoft.com/powershell-community/changing-drive-letters-and-labels-via-powershell/
$Drive = Get-CimInstance -ClassName Win32_Volume -Filter "DriveLetter = 'D:'"
$Drive | Set-CimInstance -Property @{DriveLetter='M:'; Label='Media'}
$Drive = Get-CimInstance -ClassName Win32_Volume -Filter "DriveLetter = 'E:'"
$Drive | Set-CimInstance -Property @{DriveLetter='S:'; Label='Storage'}
$Drive = Get-CimInstance -ClassName Win32_Volume -Filter "DriveLetter = 'H:'"
$Drive | Set-CimInstance -Property @{DriveLetter='D:'; Label='Data'}
$Drive = Get-CimInstance -ClassName Win32_Volume -Filter "DriveLetter = 'D:'"
$Drive | Set-CimInstance -Property @{DriveLetter='S:'; Label='Storage'}
$Drive = Get-CimInstance -ClassName Win32_Volume -Filter "DriveLetter = 'F:'"
$Drive | Set-CimInstance -Property @{DriveLetter='W:'; Label='Windows'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment