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
|
# DNS Servers $dnspri = "192.168.1.203"
$dnsalt = "192.168.1.213"
# Domain Name $domainname = "test.com"
# NTP Servers $ntpone = "10.91.168.253"
#Default Gateway $dg = "10.91.165.254"
$esxHosts = get-VMHost -Name *
foreach ( $esx in $esxHosts ) {
Write-Host "Configuring DNS and Domain Name on $esx" -ForegroundColor Green
Get-VMHostNetwork -VMHost $esx | Set-VMHostNetwork -DomainName $domainname -DNSAddress $dnspri , $dnsalt -Confirm: $false
Write-Host "Configuring Default Gateway IP on $esx" -ForegroundColor Green
Get-VMHostNetwork -VMHost $esx | Set-VMHostNetwork -ConsoleGateway $dg
Write-Host "Configuring hostname on $esx" -ForegroundColor Green
Get-VMHostNetwork -VMHost $esx | Set-VMHostNetwork -HostName $esx .Name
Write-Host "Configuring NTP Servers on $esx" -ForegroundColor Green
Add-VMHostNTPServer -NtpServer $ntpone -VMHost $esx -Confirm: $false
Write-Host "Configuring NTP Client Policy on $esx" -ForegroundColor Green
Get-VMHostService -VMHost $esx | where{ $_ .Key -eq "ntpd" } | Set-VMHostService -policy "on" -Confirm: $false
Write-Host "Restarting NTP Client on $esx" -ForegroundColor Green
Get-VMHostService -VMHost $esx | where{ $_ .Key -eq "ntpd" } | Restart-VMHostService -Confirm: $false
} |
本文转自bard_zhang51CTO博客,原文链接:http://blog.51cto.com/timefiles/1920319 ,如需转载请自行联系原作者