Thursday, August 21, 2014

Part - 8 : PowerShell and Hyper-V : Mounting ISOs to the Hyper-V Virtual Machine's DVD Drives

 

Yesterday, we have seen that how can we add a virtual disk to the Hyper-V virtual machine.

When I was writing that blog, I was also thinking about to write a article on that how can we add a ISO file to the DVD drive of the Virtual machine.

It's cool to know if you able to directly mount as ISO file to the virtual machine by using our lovely blue coloured PowerShell console.

You want to know how to do that? YES ? Great. let's started.

In the Below screenshot you can see that, currently there is no "CD / DVD Disk" mounted on the DVD Drive of my Virtual Machine "Windows 2008 R2".

1

I am hoping that by now, you already know how to get the list of all virtual machines.,

We can use the "Get-VM" cmdlet for that, and you can see that "Windows 2008 R2" virtual machine is up and running.

2

In the below screen shot, you can see a list of my all ISO files located in F:\ISO_Image folder.

I am choosing the "Windows2008R2_all_edition.ISO" file to mount to the my "Windows 2008 R2" virtual machine's DVD Drive.

4

We use the Set-VMDvdDrive cmdlet to mount the ISO file to the DVD drive of the virtual machines.

Set-VMDvdDrive -VMName 'Windows 2008 R2' -Path 
"F:\ISO_Image\Win2008R2_all_editions.iso"
In the above command, we are using  Set-VMDvdDrivecmdlet , -VMName  parameter we are providing the name of the virtual machine on which we want to mount the ISO file, and in -Path parameters we are providing the path of the ISO file which we want to mount.
In the below screenshot, you can see that command has been completed successfully.

3


and if you check the virtual machine, you can see that our ISO is mounted successfully.


5


Come-on.. Believe me Winking smile 


6


That's all for today. See you in my next blog post. Keep Smiling.


tumblr_mfxux9bqN61qzmvsio6_250

Thanks.

Aman Dhally

If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube channel for PowerShell video tutorials. You can download all of my scripts from “Microsoft TechNet Gallery”.

Wednesday, August 20, 2014

Part - 7 : PowerShell and Hyper-V : Adding Virtual Disk to the Virtual Machines in Hyper-v

 

In my previous post, we see that how can we create a new virtual hard disk.

If you remember yesterday we have creates a 5Gb of fixed hard disk image with the name of "myHDDFixed.vhd".

Today, we are going to add the same  virtual disk which we have created yesterday to the one of our prebuilt virtual machine.

As you know that we can use the Get-VM cmdlet to get the list of all of our virtual machines.

In the below screenshot, you can see all of my virtual machines. We are going to add the virtual hard disk to the  "Windows 2008 R2" virtual machine.

2

In the below screenshot you can see that there are no secondary hard disk in the "Windows 2008 R2" virtual machine.

1

Remember : We can only add virtual hard disk to the virtual machines, when they are Powered Off, You can't add virtual disk if the virtual machines in Powered ON.

Let's store the information of the "Windows 2008 R2" in to a variable, as we need this information as "Virtual Machine" object not as a plain string.

$vm = Get-VM -Name 'Windows 2008 R2'
3

We use the "Add-VMHardDiskDrive" cmdlet to add the virtual hard disk to the virtual machine.


The basic syntax of Add-VMHardDiskDrive is simple, we need to provide the path of the virtual hard disk file which we need to add to the virtual machine and the  name of the virtual machine as Virtual machine object.


In our case the the path of the virtual hard disk is "'F:\VirtualMachines\Hyper-V\myHDD\myHDDFixed.vhd' and the virtual machine is "Windows 2008 R2" , and we stored the Virtual Machine Object in $vm variable.


Add-VMHardDiskDrive -Path 'F:\VirtualMachines\Hyper-V\myHDD\myHDDFixed.vhd' -VM $vm

in the below screenshot, you can see that our command has run successfully.


4


Let's start the virtual machine and see if the new hard disk is added successfully.


5


If you check the setting of "Windows 2008 R2" virtual machine, you can see that, our "myHDDFixed.vhd" is added successfully.


6


When i opened the "Disk Management" on "Windows 2008 R2", it's showing me that one disk is added and i need to initialize it.


7


After initialize, you can see that a new 5GB of hard disk is added to the server. Smile 


8





Simple.. and easy... isn't..........


 tumblr_mfxux9bqN61qzmvsio8_250


Take care of yourself, and keep smiling, World need You..


Thanks.


Aman Dhally


If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube channel for PowerShell video tutorials. You can download all of my scripts from “Microsoft TechNet Gallery”.