Various Hyper-V Related PowerShell
#------------------------------------------------------ | |
#check currently installed roles | |
Get-WindowsFeature | where {$_.installed -eq "True"} | |
#------------------------------------------------------ | |
#------------------------------------------------------ | |
#install the Hyper-V Role | |
Install-WindowsFeature Hyper-V -IncludeManagementTools -Restart -Verbose | |
#------------------------------------------------------ | |
#----------------NIC TEAMING---------------------------- | |
# This will loop through and get all available NICs and add them to the team | |
$NICname = Get-NetAdapter | %{$_.name} | |
# New Network Team | |
New-NetLbfoTeam -Name PublicNetTeam –TeamMembers $NICname -TeamingMode SwitchIndependent -LoadBalancingAlgorithm HyperVPort -Confirm:$false | |
Start-Sleep -s 15 | |
$netadapter = Get-NetAdapter -Name PublicNetTeam; | |
$netadapter | Set-NetIPInterface -DHCP Disabled; | |
#we will now set the IP, gateway, and DNS of the new PublicNetTeam | |
$Script:primaryIP = "10.0.3.50" | |
$Script:pNetMask = "24" | |
$Script:pgateway = "10.0.3.1" | |
$Script:dns1 = "10.0.3.189" | |
$Script:dns2 = "10.0.3.1" | |
$netadapter | New-NetIPAddress -AddressFamily IPv4 -IPAddress $Script:primaryIP -PrefixLength $Script:pNetMask -Type Unicast -DefaultGateway $Script:pgateway | Out-Null; | |
Set-DnsClientServerAddress -InterfaceAlias PublicNetTeam -ServerAddresses $Script:dns1,$Script:dns2 | Out-Null | |
#---------------END NIC TEAMING------------------------- | |
#------------------------------------------------------ | |
#create new virtual switch | |
New-VMSwitch -NetAdapterName PublicNetTeam -Name "PublicVSwitch" -AllowManagementOS $true -Confirm:$false | |
#------------------------------------------------------ | |
#------------------------------------------------------ | |
#Set Default HYPER-V locations | |
SET-VMHost -virtualharddiskpath V:\VHDs | |
Set-VMHost -virtualmachinepath V:\VMs | |
#------------------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment