powerCLI随笔

PowerCLI安装完成之后,以管理员身份运行

get-executionpolicy---------查看状态确实为Restricted set-executionpolicy---------将属性从Restricted更改为remotesigned powerCLI随笔   再次启动,连接主机 connect-viserver 10.11.233.239 –user 'root' –password 'clpcpasswd' powerCLI随笔   创建虚拟标准交换机及vlan get-vmhost "10.11.233.239" |get-vmhostnetworkadapter powerCLI随笔

 

get-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 powerCLI随笔

 

获取单台主机虚拟交换机信息

$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

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
上一篇:Greenplum Python工具库gpload学习——get_fast_match_exttable_query和get_reuse_exttable_query


下一篇:Linux安装nginx