Vmware PowerCLI vSwitch和端口组设置

650阅读 0评论2013-12-05 wfeng
分类:系统运维

为了得到工作的VMotion网络设置起着重要的作用下列任何一种可能会导致的大问题

这就是为什么自动化和PowerCLI的关键是你的vSwitch和端口组的设置 你可以手动添加每个vSwitch,然后创建一个端口组为每个VLAN中继到您的主机上手动但什么是你会错过一个机会,什么是的机会,你会得到VLAN ID不正确而你肯定不觉得无聊的精灵,当你有4 vSwitch和大约20端口组

The following code will take you through copying all vSwitches and PortGroups from an existing ESX server over to a new server, ensuring they are exactly the same.  It sure does save me time !

$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 {
   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
       $vSwitch = $_
    } $_ |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
        }
    }
}
 
   
上一篇:静态路由送出接口的区别和使用
下一篇:VMware View 删除桌面池