1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#add distributed switch to datacenter
New-VDSwitch
-Name vds-vmotion -Location Dtarget
New-VDSwitch
-Name vds-prd -Location Dtarget
New-VDSwitch
-Name vds-storage -Location Dtarget
#add portgroup to distributed switch
Get-VDSwitch
vds-prd |
New-VDPortgroup
-Name 192.168.10.0 -VlanId 10
Get-VDSwitch
vds-vmotion |
New-VDPortgroup
-Name 192.168.2.0 -VlanId 2
Get-VDSwitch
vds-storage |
New-VDPortgroup
-Name 192.168.100.0 -VlanId 100
$vmhostlist
=
import-csv
E:\vmhostlist.csv
foreach
(
$vmhost
in
$vmhostlist
){
#config dns,domainname,ntpserver to vmhost
Get-VMHostNetwork
-VMHost
$vmhost
.ip |
Set-VMHostNetwork
-DnsFromDhcp
$false
-DnsAddress 192.168.1.254 -DomainName test.org
Add-VMHostNtpServer
-VMHost
$vmhost
.ip -NtpServer 192.168.1.254
Get-VMHostService
-VMHost
$vmhost
.ip | where {
$_
.Key
-eq
"ntpd"
} |
Start-VMHostService
Get-VMHostService
-VMHost
$vmhost
.ip | where {
$_
.Key
-eq
"ntpd"
} |
Set-VMHostService
-Policy Automatic
#add vmhost to distributed switch
Get-VDSwitch
-Name vds-* |
Add-VDSwitchVMHost
-VMHost
$vmhost
.ip
#add physicol adapter to standard switch up link
$myVMHostNetworkAdapter
=
Get-VMhost
$vmhost
.ip |
Get-VMHostNetworkAdapter
-Physical -Name vmnic1
Get-VirtualSwitch
-VMHost
$vmhost
.ip -Name
"vSwitch0"
|
Add-VirtualSwitchPhysicalNetworkAdapter
-VMHostPhysicalNic
$myVMHostNetworkAdapter
-Confirm:
$false
#add physicol adapter to distributed switch up link
$nic
=
Get-VMhost
$vmhost
.ip|
Get-VMHostNetworkAdapter
-Physical -Name vmnic2,vmnic3
Get-VDSwitch
-VMHost
$vmhost
.ip -Name vds-prd |
Add-VDSwitchPhysicalNetworkAdapter
-VMHostPhysicalNic
$nic
-Confirm:
$false
$nic
=
Get-VMhost
$vmhost
.ip|
Get-VMHostNetworkAdapter
-Physical -Name vmnic4,vmnic5
Get-VDSwitch
-VMHost
$vmhost
.ip -Name vds-vmotion |
Add-VDSwitchPhysicalNetworkAdapter
-VMHostPhysicalNic
$nic
-Confirm:
$false
$nic
=
Get-VMhost
$vmhost
.ip |
Get-VMHostNetworkAdapter
-Physical -Name vmnic6,vmnic7
Get-VDSwitch
-VMHost
$vmhost
.ip -Name vds-storage |
Add-VDSwitchPhysicalNetworkAdapter
-VMHostPhysicalNic
$nic
-Confirm:
$false
#add vmkernel vMotion adn vsan traffic
New-VMHostNetworkAdapter
-VMHost
$vmhost
.ip -VirtualSwitch vds-vmotion -PortGroup 192.168.2.0 -IP
$vmhost
.vmotionip -SubnetMask 255.255.255.0 -VMotionEnabled
$true
New-VMHostNetworkAdapter
-VMHost
$vmhost
.ip -VirtualSwitch vds-storage -PortGroup 192.168.100.0 -IP
$vmhost
.storageip -SubnetMask 255.255.255.0 -VsanTrafficEnabled
$true
}
|
本文转自bard_zhang51CTO博客,原文链接: http://blog.51cto.com/timefiles/1967853,如需转载请自行联系原作者