Tuesday, July 22, 2014

Part - 2 : PowerShell and Hyper-V : Virtual Switch

 

1. Part 1 :  PowerShell and Hyper-V : Getting Started

 

"Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.- Dr. Seuss"

In my previous post, we have seen the basic of "PowerShell and Hyper-V". That shows how to install Hyper-V and how to get the list of all virtual machines (those were pre-created).

Today, we are going create a new virtual switch.

What is a virtual switch?

In a simple language, it is virtual switch is virtual like virtual machines. Our Virtual machines need to connect with either each other, or with our physical machines, By using virtual switch, we can create a LAN environment.  We can created multiple LAN environment using these Virtual switches.

There are 3 types of virtual switches.

  1. External
  2. Internal
  3. Private

External :

In external switch, our virtual machine is able to talk with all of resources available on our physical network.

Internal :

Using internal switch, our virtual machine is only able to talk with the host and other virtual machines.

Private:

Private switch allow communication between the virtual machines on the host that's all.

Let's get started.

I am going to create a new External virtual switch.

Hyper-V external virtual switches are  bind on the physical lan/wifi adapter by which they can connected to physical environment.

To get the list of all network adapters we can use  Get-NetAdapter cmdlet.

22-07-2014 15-45-20

22-07-2014 15-44-39

 I am connected to my physical network using my LAN card named as "Ethernet". I will bind "Virtual External Switch" on "Ethernet" lan.

To create a new virtual switch we use New-VMSwitch cmdlet.

To list all of your Virtual switches, use the cmdlet,Get-VMSwitch

You can see that, currently, there is no virtual switch which is connected to External network.,

22-07-2014 15-49-26

22-07-2014 15-47-37

Creating external switch is simple. We just need to name of the External virtual swtich, and then name of our LAN/WiFI adapter name and that's all.

The command is : 

New-VMSwitch -Name "Connect_toThe_World" -NetAdapterName 'Ethernet' -AllowManagementOS $true

22-07-2014 15-48-12


And you can see that , new External Switch is created.


22-07-2014 17-41-38


If you want to create an internal or private switch, you mainly need two parameters with New-VMSwitch cmdlet, -Name and -SwitchType


Creating Internal virtual switch.

 New-VMSwitch -Name "my_lonely_world" -SwitchType Internal
22-07-2014 18-24-21

Creating Private virtual switch.


New-VMSwitch -Name "I_M_Secret" -SwitchType Private


22-07-2014 18-27-01


and you can see the list of all virtual switches.


22-07-2014 18-27-59


That's all for now Smile See you in my next blog posts.


 


searching-tumblr


Thanks.


Aman Dhally


 


Come and join my journey of : “100 Days of Self Improvement” on



Facebook: https://www.facebook.com/100DoSI 



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”.

Monday, July 14, 2014

PowerShell and Hyper-V : Getting Started

 

“ To live is the rarest thing in the world. Most people exist, that is all.― Oscar Wilde ”

After writing article on “Desired State Configuration”, I was thinking about topics on which I can write a similar article series.  Nothing was coming to my mind, as I already covered “Active Directory”, “Desired State configuration”, “DHCP”, “Event Viewer” and other topics.

As I use “Hyper-V” a lot, then I thought why not to write a 0 – 200 level series of articles on “Hyper-V”? to me it seems to be good idea J and I hope you may like it too.

I love "Hyper-v", before using "Hyper-V", I used to have "VMware Workstation" , but after migrating to windows 8.1 and start using "Hyper-V" I never used "VMware Workstation" again.

Let’s get started.

Prerequisites

·        Windows 8.1

·        Try to have at-least 4 GB of minimum Ram.

·        64 Bit processor

 

Yes, that’s all.

Step 1 :

Go to the BIOS Setting of your System / Laptop and enable Virtualisation.

photo

Step 2 :

    • Boot your System
    • Go to Control Panel
    • Click on "Programs and features"
    • Click on "Turn windows feature On of Off"
    • Select all features and sub features of "Hyper-V"
    • and Click on "OK"
    • 14-07-2014 15-09-49

 

 

Step 3 :

    • Open PowerShell Console.
    • There is no need to Import Hyper-V module , as after PowerShell v3, they all auto imported.
      Import-Module Hyper-V


    • 14-07-2014 14-38-13


    • To know the list of all cmdlets imported by Hyper-V module , you can run the simple command
      Get-Command -Module 'Hyper-V'


    • 14-07-2014 14-39-02

 


 


Step 4 :



Let's run basic cmdlets for now.





    • To get the list of "Hyper-V" hosts, run the cmdlet, Get-VMHost


    • 14-07-2014 14-40-06


    • If you want to see the list of all virtual machines, just run the cmdlet Get-VM.


    • 14-07-2014 14-40-28


    • and you can see that all of machines are Off. you can cross verify it  by open a Hyper-V management console. Smile 


    • 14-07-2014 14-40-53

 


That's all of now and hope to see you in next blog post.


 


Thanks & Regards


Aman Dhally


loki-2


 






Come and join my journey of : “100 Days of Self Improvement” on



Facebook: https://www.facebook.com/100DoSI 



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”.