PowerTip: Use PowerShell to Add Drive to Virtual Machine

Summary: Use Windows PowerShell to add a new hard disk drive to a virtual machine on Hyper-V.

Hey, Scripting Guy! Question How can I to add another hard drive to my virtual machine?

Hey, Scripting Guy! Answer Use the Add-VMHardDiskDrive cmdlet with the following command:

STOP-VM -vmname "My Virtual Machine"

NEW-VHD -Dynamic C:\VHD\MyDrive.vhdx -SizeBytes 60GB

ADD-VMHardDiskDrive -vmname "My Virtual Machine" -path C:\VHD\MyDrive.VHDX

START-VM -vmname "My Virtual Machine"

Comments (1)

  1. Kristan says:

    How to determine whether you'll add it in ide controller or scsi controller because it's critical..best practice is to add hard-disk in scsi controller if its not the boot disk. But this script will use IDE controller.

Skip to main content