Copy vSwith portgroup from an existing ESXi host
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Copy vSwith portgroup from an existing ESXi host相关的知识,希望对你有一定的参考价值。
Script
------------------------------------------------------------------------------------------
##
## http://www.virtu-al.net/2009/06/27/powercli-easy-vswitch-portgroup-setup/
## copying all vSwitches and PortGroups from an existing ESX server over to a new server
Add-PSSnapin vmWARE.VimAutomation.Core
$VISRV = Connect-VIServer (Read-Host "Please enter the name of your VI SERVER")
$BASEHost = Get-VMHost -Name (Read-Host "Please enter the name of your existing server as seen in the VI Client:")
$NEWHost = Get-VMHost -Name (Read-Host "Please enter the name of the server to configure as seen in the VI Client:")
$BASEHost |Get-VirtualSwitch |Foreach {
$vSwitch = $_
If (($NEWHost |Get-VirtualSwitch -Name $_.Name-ErrorAction SilentlyContinue)-eq $null){
Write-Host "Creating Virtual Switch $($_.Name)"
$NewSwitch = $NEWHost |New-VirtualSwitch -Name $_.Name-NumPorts $_.NumPorts-Mtu $_.Mtu
}
$_ |Get-VirtualPortGroup |Foreach {
If (($NEWHost |Get-VirtualPortGroup -Name $_.Name-ErrorAction SilentlyContinue)-eq $null){
Write-Host "Creating Portgroup $($_.Name)"
$NewPortGroup = $NEWHost |Get-VirtualSwitch -Name $vSwitch |New-VirtualPortGroup -Name $_.Name-VLanId $_.VLanID
}
}
}
以上是关于Copy vSwith portgroup from an existing ESXi host的主要内容,如果未能解决你的问题,请参考以下文章
Export portgroup from the host