June 21st, 2013

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

Doctor Scripto
Scripter

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  

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback