Import portgroup to the host

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Import portgroup to the host相关的知识,希望对你有一定的参考价值。

CSV format

------------------------------------------------------------------------------------------

技术分享


Script

------------------------------------------------------------------------------------------

#[cluster,vSwitch,VLANname,VLANid]

# e.g: cluster name,vSwitch0,VM_network,192.168.0.0,11

 

Add-PSSnapin vmWARE.VimAutomation.Core

$vc="vcntername"
connect-viserver $vc


# Set the input file

$InputFile = "C:\PS\Import_PortGroup\All_PortGroup_SIT_20161202.csv"

 

# Read the import file

$MyVLANFile = Import-CSV $InputFile

 

# Parse the input file and add the virtual port groups accordingly

 

ForEach ($VLAN in $MyVLANFile) {

  $MyCluster = $VLAN.cluster

  $MyvSwitch = $VLAN.vSwitch

  $MyVLANname = $VLAN.VLANname

  $MyVLANid = $VLAN.VLANid

 

 

  # Query the cluster to retrieve the hosts

  $MyVMHosts = Get-Cluster $MyCluster | Get-VMHost | sort Name | % {$_.Name}

 

  # Loop through the hosts and add the virtual port group to our vswitch based on the input

  ForEach ($VMHost in $MyVMHosts) {

  Get-VirtualSwitch -VMHost $VMHost -Name $MyvSwitch | New-VirtualPortGroup -Name $MyVLANname -VLanId $MyVLANid

  }

}

以上是关于Import portgroup to the host的主要内容,如果未能解决你的问题,请参考以下文章

Add PortGroup to all hosts in cluster with PowerCLI

[Redux] Adding React Router to the Project

Error:Unable to make the module:***, related gradle configuration was not found. Please, re-import t

Xcode工程编译错误:“Cannot assign to 'self' outside of a method in the init family”

关于fastapi开启多个服务实例时遇到WARNING: You must pass the application as an import string to enable 'reloa

The import java.io cannot be resolved