hi Luc,
can you check if this is the corrrect way of starting ntp service
$clu=read-host "provide cluster name"
$cluster=Get-Cluster -Name $clu
$vmhosts=get-vmhost -Location $cluster
foreach($vmhost in $vmhosts)
{
$ntpd=Get-VMHostService -VMHost $vmhost|?{$_.Key -eq 'ntpd'}
$ntpd.Running
if($ntpd.Running -eq 'false')
{
$ntpd|Start-VMHostService -WhatIf
}
}
Yes, that will work, but I would be tempted to do it in more 'PowerShell' kind of way.
Get-Cluster -Name $clu |
Get-VMHost |
Get-VMHostService |
where {$_.Key -eq 'ntpd' -and -not $_.Running} |
Start-VMHostService -Confirm:$false -WhatIf
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, that will work, but I would be tempted to do it in more 'PowerShell' kind of way.
Get-Cluster -Name $clu |
Get-VMHost |
Get-VMHostService |
where {$_.Key -eq 'ntpd' -and -not $_.Running} |
Start-VMHostService -Confirm:$false -WhatIf
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thnaks Luc it is working .and it is more poweshellish way using pipelines.