NTP check with Powercli
Oneliners to speed up troubleshooting common NTP related issues.
Connect-ViServer <vCenter address> -user administrator@vsphere.local -password VMware123!
Check NTP Server is configured.
Get-VMHost |Sort Name|Select Name, @{N=“NTPServer“;E={$_ |Get-VMHostNtpServer}}, @{N=“ServiceRunning“;E={(Get-VmHostService -VMHost $_ |Where-Object {$_.key-eq “ntpd“}).Running}}
Check timestamp for ESXi host.
foreach($esxcli in get-vmhost|get-esxcli){“”|select @{n=’Time’;e={$esxcli.system.time.get()}},@{n=’hostname’;e={$esxcli.system.hostname.get().hostname}} }
Set time manually on esxi host.
Directly on host: esxcli system time set -H 03 -m 29 -s 40
H =Hour
m = minute
s = mecond
$esxlist = get-vmhost
foreach ($_ in $esxlist) {$esxcli = Get-EsxCli -VMHost $_; $esxcli.system.time.get();}
Set time via powercli
$DevHost.system.time.set.help()
owerCLI C:\TEMPP> $DevHost.system.time.set.help()
=======================================================================================
im.EsxCLI.system.time.set
—————————————————————————————
et the system clock time. Any missing parameters will default to the current time
aram
—————————————————————————————
day | Day
hour | Hour
min | Minute
month | Month
sec | Second
year | Year
Example
For all hosts.
$esxlist = get-vmhost
foreach ($_ in $esxlist) {$esxcli = Get-EsxCli -VMHost $_; $esxcli.system.time.get();}
foreach($_ in $esxlist){$esxcli = Get-EsxCli -VMHost $_; $esxcli.system.time.set(10,09,53,01,20,2019); }
/// Parameters are ///
(day,hour,minute,month,second,year)
Categories
2 thoughts on “NTP check with Powercli” Leave a comment ›