Skip navigation
Change DVD drive letter using PowerShell

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-null

Get-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 

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish