Saturday, March 14, 2015

Creating Hyper-V virtual switch with powershell selection


Creating virtual switch each time for your lab, might be frustrating. The above will give you some minor steps that you could do to increase the productivity of creation on your end. What you can do is to use windows powershell to create those switch as you want.

In the next article, I will share more on the combination script to use for VM creation as well. Now we will just be focusing on switch creation.

#To clear the screen
#To get the current network adapter
#Base on the current network adapter, you should select the interface that you would like to use for the switch creation

$interface = read-host "Please enter your interface for public switch: "
$ethernet = Get-NetAdapter -Name $interface
$switchname = read-host "Please enter your switchname : "
$switchtype = read-host "Please enter your switch type (internal, private or public) : "
if ($switchtype -like 'internal')
New-VMSwitch -name $switchname -SwitchType internal
elseif ($switchtype -like 'private')
New-VMSwitch -name $switchname -SwitchType private
elseif ($switchtype -like 'public')
New-VMSwitch -Name $switchname -NetAdapterName $
write-host "You have input an invalid switchtype" -ForegroundColor Yellow

Stay tune with my next articles. Let us know what you though , learns and hope for next articles!. Connect with us on GOOGLE+ , TWITTER and FACEBOOK.

No comments:

Post a Comment