#Start of Script
############################################
#Configure DNS
#Configure NTP,
#Configure Domain
#compiled by : MrAmbiG
############################################
#prompt for vCenter details
$VC = Read-Host “vCenter IP?”
$VCuser = Read-Host “vCenter administrator username?”
$VCpass = Read-Host “vCenter Password?”
#connect to vCenter
Connect-VIServer $VC -User $VCuser -Password $VCpass -SaveCredentials
Write-Verbose "connecting to vCenter" -foregroundcolor Cyan
#prompt for DNS, NTP, Domain information
$dns1 = read-host "Enter Primary DNS IP"
$dns2 = read-host "Enter Secondary DNS IP"
$ntp1 = read-host "Enter Primary NTP IP"
$ntp2 = read-host "Enter Secondary NTP IP"
$domain = read-host "Enter the Domain name ex:- vce.local"
#listing hosts
$esxHosts = get-VMHost
#looping the script for each host
foreach ($esx in $esxHosts)
{
Write-Host "Configuring DNS and Domain Name on $esx" -ForegroundColor Magenta
Get-VMHostNetwork -VMHost $esx | Set-VMHostNetwork -DomainName $domain -DNSAddress $dns1 , $dns2 -Confirm:$false
Write-Host "Configuring NTP Servers on $esx" -ForegroundColor Green
Add-VMHostNTPServer -NtpServer $ntp1 , $ntp2 -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 Blue
Get-VMHostService -VMHost $esx | where{$_.Key -eq "ntpd"} | Restart-VMHostService -Confirm:$false
}
Write-Host "b33 is all done here, have a good one; End of Script" -foregroundcolor Blue
#End of Script
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
No comments:
Post a Comment