Wednesday, May 4, 2016

PowerShell script to setup all ESX Host NTP clients service to "Stopped"

# PowerCLI Script to Configure NTP on ESXi Hosts
# PowerCLI Session must be connected to vCenter Server using Connect-VIServer

#Prompt for NTP Servers
$ntpone = read-host "Enter NTP Server One"
$ntptwo = read-host "Enter NTP Server Two"

$esxHosts = get-VMHost

foreach ($esx in $esxHosts) {

   Write-Host "Configuring NTP Servers on $esx" -ForegroundColor Green
   Add-VMHostNTPServer -NtpServer $ntpone , $ntptwo -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 "off" -Confirm:$false

   Write-Host "Stop NTP Client on $esx" -ForegroundColor Green
   Get-VMHostService -VMHost $esx | where{$_.Key -eq "ntpd"} | Stop-VMHostService -Confirm:$false

}
Write-Host "Done!" -ForegroundColor Green
Write-Host "Done!" -ForegroundColor Green

************************************************************************
example to stop NTP client on all ESX host in vCenter
#all esx host#$esxHosts = get-VMHost
#per machine# $esxHosts = get-VMHost pbtp-esxi-charlie-05.st.com
$esxHosts = get-VMHost

foreach ($esx in $esxHosts) {

    Write-Host "Configuring NTP Client Policy on $esx" -ForegroundColor Green
   Get-VMHostService -VMHost $esx | where{$_.Key -eq "ntpd"} | Set-VMHostService -policy "off" -Confirm:$false

   Write-Host "Stop NTP Client on $esx" -ForegroundColor Green
   Get-VMHostService -VMHost $esx | where{$_.Key -eq "ntpd"} | Stop-VMHostService -Confirm:$false

}
Write-Host "Done!" -ForegroundColor Green
Write-Host "Done!" -ForegroundColor Green

**************************************************************************



Windows Server VM time check commands:
In the command line, type
w32tm /query /configuration
w32tm /query /status
Time /T 
w32tm /query /configuration gives you the configuration you have set up.
w32tm /query /status gives you information such as:
  • stratum
  • leap indicator
  • precision
  • last sync
  • NTP server
  • poll interval
time /T outputs the current system time.




http://blog.itsysintegration.net/vmware-powercli-configure-dns-server-the-dns-domain-and-ntp-services/

No comments:

Post a Comment

Vmware NSX SSL creation 

Using OpenSSL for NSX Manager SSL import: Creates CSR and 4096 bit KEY Creating NSX 6.4.2 SSL    openssl req -out nsxcert.csr -newkey rsa:40...