# 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 }
批量配置esix主机dns,hostname,ntp
原创bard_zhang 博主文章分类:PowerShell ©著作权
文章标签 get powercli vmhostnetwork 文章分类 运维
上一篇:Powercli 导出虚拟机清单
-
ubuntu下IP、DNS、hostname的配置
一、配置ip ubuntu的网络配置信息放在 /etc/network/interfaces 中, 如果配置动态获取ip,则在上述文件中加入以下内容: auto eth0 iface eth0 inet dhc
service address 网络服务 networking gateway -
ansible之批量配置dns
批量配置/etc/hosts
ansible 批量配置