Change DVD drive letter using PowerShell

Change the DVD drive letter with a few lines of PowerShell.

John Savill

August 27, 2016

1 Min Read
Change DVD drive letter using PowerShell

Q. How can I change the drive letter for a DVD drive using PowerShell?

A. I recently needed to use the E: drive for data in an Azure VM but by default the E: drive is used for the DVD drive. I needed to configure this using an unattended configuration and used the following PowerShell to not only change the drive letter for the DVD drive but then automatically initialize and create data volumes on the two data disks I had added to my VM.

#Change CD drive letter$drv = Get-WmiObject win32_volume -filter 'DriveLetter = "E:"'$drv.DriveLetter = "L:"$drv.Put() | out-nullGet-Disk -Number 2 | New-Partition -UseMaximumSize -DriveLetter E | Format-Volume -FileSystem NTFS -NewFileSystemLabel "Data1" -Confirm:$False Get-Disk -Number 3 | New-Partition -UseMaximumSize -DriveLetter F | Format-Volume -FileSystem NTFS -NewFileSystemLabel "Data2" -Confirm:$False 

 

About the Author(s)

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like