Open AutomateIT1979 opened 4 years ago
Let's check some facts:
If the script is trying to delete the secondary NTP like you see here: Remove-VMHostNtpServer : 26/09/2020 16:28:41 Remove-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' does not exist on VMHost 'ESX03.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:44 char:60
... _.$domain" | Remove-VMHostNtpServer -NtpServer $ntp2 -Confirm:$false}
Is because the script detects that the primary NTP is missing and then delete the secondary NTP to maintain the right order. So if the primary NTP don't exist, deletes the secondary because the system has an order and if the script add the primary after the secondary, then the secondary becomes the primary. That's why try to delete the secondary to add the Servers in the right order. If you see that message I understand that you don't have any NTP server configured at the moment you run the script.
Then you see: Add-VMHostNtpServer : 26/09/2020 16:28:43 Add-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' already exist on VMHost 'ESX03.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
... .$domain" | Add-VMHostNtpServer -NtpServer $ntp1,$ntp2 -Confirm:$fals ...
And is the same thing. You put the primary NTP, when the script checks and see that the primary NTP don't exist, try to delete the secondary, but the secondary don't exist, then try to add the two NTP in the right order, but one of them already exist.
I think this issue is because the information that you put in the variable. Let me know this:
.- When you configure the NTP Servers the primary and secondary NTP Servers are different? .- You have at least one NTP Server configured? .- What shows the file ntp.txt?
.- When you configure the NTP Servers the primary and secondary NTP Servers are different?
.- You have at least one NTP Server configured?
.- What shows the file ntp.txt?
when I run the script the output show an error for NTP ###############################################
Checking NTP Servers...
############################################### Server XXX.XXX.XXX.XXX is missing Remove-VMHostNtpServer : 26/09/2020 16:28:41 Remove-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' does not exist on VMHost 'ESX03.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:44 char:60
Remove-VMHostNtpServer : 26/09/2020 16:28:41 Remove-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' does not exist on VMHost 'ESX03.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:44 char:60
Remove-VMHostNtpServer : 26/09/2020 16:28:41 Remove-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' does not exist on VMHost 'ESX03.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:44 char:60
Remove-VMHostNtpServer : 26/09/2020 16:28:42 Remove-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' does not exist on VMHost 'ESX02.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:44 char:60
Remove-VMHostNtpServer : 26/09/2020 16:28:42 Remove-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' does not exist on VMHost 'ESX02.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:44 char:60
Remove-VMHostNtpServer : 26/09/2020 16:28:42 Remove-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' does not exist on VMHost 'ESX02.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:44 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:43 Add-VMHostNtpServer The NtpServer 'XXX.XXX.XXX.XXX' already exist on VMHost 'ESX03.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
XXX.XXX.XXX.XXX YYY.YYY.YYY.YYY Add-VMHostNtpServer : 26/09/2020 16:28:43 Add-VMHostNtpServer The NtpServer 'XXX.XXX.XXX.XXX' already exist on VMHost 'ESX03.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:43 Add-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' already exist on VMHost 'ESX03.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:43 Add-VMHostNtpServer The NtpServer 'XXX.XXX.XXX.XXX' already exist on VMHost 'ESX03.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:43 Add-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' already exist on VMHost 'ESX03.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:43 Add-VMHostNtpServer The NtpServer 'XXX.XXX.XXX.XXX' already exist on VMHost 'ESX03.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:43 Add-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' already exist on VMHost 'ESX03.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:43 Add-VMHostNtpServer The NtpServer 'XXX.XXX.XXX.XXX' already exist on VMHost 'ESX02.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
XXX.XXX.XXX.XXX YYY.YYY.YYY.YYY Add-VMHostNtpServer : 26/09/2020 16:28:43 Add-VMHostNtpServer The NtpServer 'XXX.XXX.XXX.XXX' already exist on VMHost 'ESX02.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:43 Add-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' already exist on VMHost 'ESX02.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:44 Add-VMHostNtpServer The NtpServer 'XXX.XXX.XXX.XXX' already exist on VMHost 'ESX02.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:44 Add-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' already exist on VMHost 'ESX02.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:44 Add-VMHostNtpServer The NtpServer 'XXX.XXX.XXX.XXX' already exist on VMHost 'ESX02.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:44 Add-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' already exist on VMHost 'ESX02.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:44 Add-VMHostNtpServer The NtpServer 'XXX.XXX.XXX.XXX' already exist on VMHost 'ESX01.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:44 Add-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' already exist on VMHost 'ESX01.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:44 Add-VMHostNtpServer The NtpServer 'XXX.XXX.XXX.XXX' already exist on VMHost 'ESX01.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:44 Add-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' already exist on VMHost 'ESX01.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:44 Add-VMHostNtpServer The NtpServer 'XXX.XXX.XXX.XXX' already exist on VMHost 'ESX01.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:44 Add-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' already exist on VMHost 'ESX01.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:44 Add-VMHostNtpServer The NtpServer 'XXX.XXX.XXX.XXX' already exist on VMHost 'ESX01.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Add-VMHostNtpServer : 26/09/2020 16:28:44 Add-VMHostNtpServer The NtpServer 'YYY.YYY.YYY.YYY' already exist on VMHost 'ESX01.TEST.LOCAL'. At K:\Scripts\testScript_Test_Hardening.ps1:45 char:60
Server XXX.XXX.XXX.XXX was added successfully ###############################################
Verifying NTP services...
############################################### All NTP Services are started.