Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Scripting the Removal of Physical disk from VM

$
0
0

Hi all

I have read this thread here which has helped me so far to create a script for the removal of a VM Hard Disk Drive

http://social.technet.microsoft.com/Forums/windowsserver/en-US/7f00687c-aa8b-4125-a10c-2730ee473e78/auto-add-remove-physical-disk-from-hyperv-vms?forum=winserverhyperv

So far the script I have knocked up is as follows:

Remove

PS C:\Users\Administrator> remove-vmhardDiskDrive -VMName 2012r2 -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0

Re-add

PS C:\Users\Administrator> add-vmhardDiskDrive -VMName 2012r2 -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0

This gets me this in the Hyper-V settings:

I need the script to add the VM Hard Disk drive in with the physical hard disk selected automatically.

Is there a way to do this?

As you can see I am not a powershell expert, im not even an "expert"

Thanks - Dan 


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>