powerCLI随笔
作者:互联网
PowerCLI安装完成之后,以管理员身份运行
get-executionpolicy---------查看状态确实为Restricted set-executionpolicy---------将属性从Restricted更改为remotesigned 再次启动,连接主机 connect-viserver 10.11.233.239 –user 'root' –password 'clpcpasswd' 创建虚拟标准交换机及vlan get-vmhost "10.11.233.239" |get-vmhostnetworkadapterget-vmhost "10.11.233.239" |new-virtualswitch -name "vSwitch4" -nic vmnic6,vmnic7 get-vmhost "10.11.233.239" |get-virtualswitch -name "vSwitch4" |new-virtualportgroup -name vlan666 -vlanid 666
获取单台主机虚拟交换机信息
$switchs = get-vmhost "10.11.233.239" |get-virtualswitch &{foreach($switch in $switchs){ foreach($pg in (get-virtualportgroup -virtualswitch $switch)){ select -Inputobject $pg -Property @{N="ESXi Host";E={$switch.vmhost.name}}, @{N="vSwitch Name";E={$switch.name}}, @{N="Active NIC";E={[string]::Join(',',$switch.extensiondata.spec.policy.nicteaming.nicorder.activenic)}}, @{N="Standby NIC";E={[string]::Join(',',$switch.extensiondata.spec.policy.nicteaming.nicorder.standbynic)}}, @{N="PortGroup";E={$pg.name}}, @{N="VLAN";E={$pg.vlanid}} } }} | export-csv c:\data\networkadapter.csv
获取集群虚拟交换机信息
$switchs = get-cluster "生产中心_cluster" | get-vmhost |get-virtualswitch &{foreach($switch in $switchs){ foreach($pg in (get-virtualportgroup -virtualswitch $switch)){ select -Inputobject $pg -Property @{N="ESXi Host";E={$switch.vmhost.name}}, @{N="vSwitch Name";E={$switch.name}}, @{N="Active NIC";E={[string]::Join(',',$switch.extensiondata.spec.policy.nicteaming.nicorder.activenic)}}, @{N="Standby NIC";E={[string]::Join(',',$switch.extensiondata.spec.policy.nicteaming.nicorder.standbynic)}}, @{N="PortGroup";E={$pg.name}}, @{N="VLAN";E={$pg.vlanid}} } }} | export-csv c:\data\生产中心_cluster_portgroups_all.csv
标签:virtualswitch,name,get,vmhost,switch,pg,powerCLI,随笔 来源: https://www.cnblogs.com/hym-by/p/15487421.html