PowerTip: Use PowerShell to Add Disks to a Live Virtual Machine

Doctor Scripto

Summary: Use Windows PowerShell to add disks to a live virtual machine on Hyper-V. Hey, Scripting Guy! Question How can I easily add disk drives to my virtual machine while it is live?

Hey, Scripting Guy! Answer Use the Add-VMScsiController and Add-VMHardDiskDrive cmdlets.

First, stop the virtual machine, add the SCSI controller, then start the virtual machine:

STOP-VM “My Virtual Machine”

ADD-VMScsiController -VMname “My Virtual Machine”

START-VM “My Virtual Machine”

Now attach disks live:

NEW-VHD -Dynamic C:VHDMyDrive.vhdx -SizeBytes 60GB

ADD-VMHardDiskDrive -vmname “My Virtual Machine” -path C:VHDMyDrive.VHDX -ControllerType SCSI  

0 comments

Discussion is closed.

Feedback usabilla icon