From d2544c9418135da410670f0d5f2e89ea71c9f347 Mon Sep 17 00:00:00 2001 From: Markus Kraus Date: Sat, 30 May 2020 20:59:57 +0200 Subject: [PATCH] Other loop for "Remove all existing NTP Servers" --- Scripts/Set-VMHostSecureNTP.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/Set-VMHostSecureNTP.ps1 b/Scripts/Set-VMHostSecureNTP.ps1 index c491331..773e016 100644 --- a/Scripts/Set-VMHostSecureNTP.ps1 +++ b/Scripts/Set-VMHostSecureNTP.ps1 @@ -77,8 +77,8 @@ function Set-VMHostSecureNTP { ## Remove all existing NTP Servers "Remove all existing NTP Servers ..." try { - foreach ($OldNtpServer in ($MyHost | Get-VMHostNtpServer)) { - $MyHost | Remove-VMHostNtpServer -NtpServer $OldNtpServer -Confirm:$false + $MyHost | Get-VMHostNtpServer | Foreach-Object { + Remove-VMHostNtpServer -VMHost $MyHost -NtpServer $_ -Confirm:$false } } catch [System.Exception] {