PowerTip: Use PowerShell to Add Drive to Virtual Machine

PowerTip: Use PowerShell to Add Drive to Virtual Machine

  • Comments 1
  • Likes

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"

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • 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.