VMware Powershell NTP Service Setup
#####################################################################
#
# Setup NTP on a new host
#
$vcs = Read-Host "vCenter"
$user = Read-Host "userid"
$pw = Read-Host "Password for $user" -AsSecureString
#convert $pw to plain text
$pass = [Runtime.InteropServices.Marshal]::PtrToStringAuto(
[Runtime.InteropServices.Marshal]::SecureStringToBSTR($pw))
connect-viserver -Server $vcs -User $user -Password $pass
$pass = " "
clear-host
foreach ($VMHost in (Get-VMHost -Name privh*)) {
" $VMHost"
$ntp=get-vmhostservice -vmhost $VMHost | Where {$_.Key -eq 'ntpd'}
" $ntp"
set-vmhostservice -hostservice $ntp -policy "automatic"
restart-vmhostservice $ntp -confirm:$false
}
disconnect-viserver -confirm:$false
No comments:
Post a Comment