PowerCli – Ensure NTP time synchronization is configured properly

Loading

In this blog, we will ensure NTP is synced across all hosts evenly

#

#####################################################################
#  Ensure NTP time synchronization is configured properly #
# Tested by Ash on 28 Oct
# V1.0
######################################################################
  
#Variables
$vCenter = "sfo-m01-vc02.ash.local"
$Cluster = "Production-vSAN"
$NTPServers = "172.16.11.136" ,"172.16.11.137" 

  
### Start of Scripth
# Load VMware Cmdlet and connect to vCenter
Add-PSSnapin vmware.vimautomation.core
connect-viserver -server $vCenter
$VMHost = Get-Cluster -Name $Cluster | Get-VMhost

# List the NTP Settings for all hosts
Get-VMHost | Select Name, @{N="NTPSetting";E={$_ | Get-VMHostNtpServer}}

# Pause for user input
pause 
  
# Set the NTP Settings for all hosts
ForEach ($VMhost in $Cluster){
Write-Host -ForegroundColor GREEN "Reconfiguring NTP " -NoNewline
Write-Host -ForegroundColor YELLOW "$VMhost"
Get-VMHost | Add-VmHostNtpServer $NTPServers
}

### End of Script


(Visited 91 times, 1 visits today)

By Ash Thomas

Ash Thomas is a seasoned IT professional with extensive experience as a technical expert, complemented by a keen interest in blockchain technology.

Leave a Reply