The first one checks the state of the hosts' NTP settings/services. The second script sets the NTP servers and activates the NPT service. However the original script only works with one NTP server and we always have 2 NTP servers on our hosts. So I modified the script to allow for 2 NTP servers per host, and it seems to work, however I'm not sure if this is the most efficient way to do this.
The original script which sets the one NTP server and activates the NTP service:
My concern is that there are a lot of "Get-VMHost" commands which may slow down the script, maybe with one-liners this is how it's done, but I much prefer using structured code with loops so I'm going to modify the code so that it only gets the required properties once, and setting the NTP servers this way should not be a problem. But I still would like to know if the modified script is the way to go with the one-liner version?