# How to rename the drive letter in Windows using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

We can rename a drive letter of a disk using PowerShell with the Set-Partition command. An example is shown below.

In the Windows OS, we have E: and we need to rename its partition to the F: You can run the below command.

Set-Partition -DriveLetter 'E' -NewDriveLetter 'F'

You can also run the Get-Partition command and Pipeline the Set-Partition command. For example,

Get-Partition -DriveLetter 'E' | Set-Partition -NewDriveLetter 'F'

If you want to rename the drive on the remote computer, then you need to take the CIMSession of the system and run the command. For example,

$sess = New-CimSession -ComputerName 'Test1-Win2k12' Set-Partition -CimSession$sess -DriveLetter 'E' -NewDriveLetter 'F'
Published on 20-Nov-2020 13:15:02