powershell 各种Hyper-V相关的PowerShell

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 各种Hyper-V相关的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
#------------------------------------------------------

以上是关于powershell 各种Hyper-V相关的PowerShell的主要内容,如果未能解决你的问题,请参考以下文章

Windows Server 2012 R2 Hyper-V PowerShell远端安装Hyper-V

Hyper-V 2016 系列教程39 在 Windows 10中使用 Hyper-V 和 Windows PowerShell

PowerShell 创建Hyper-v 虚拟机

powershell 通过PowerShell使用Hyper-V和快照/检查点

使用PowerShell管理Hyper-v

powershell 通过Powershell禁用/启用Hyper-V(“以管理员身份运行”)