nrventre / vmware-esxi-hardening

Powershell script to apply hardening recomendation in ESXi hosts 6.5 and 6.7
GNU General Public License v3.0
2 stars 1 forks source link

NTP output errors #1

Open AutomateIT1979 opened 4 years ago

AutomateIT1979 commented 4 years ago

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.

nrventre commented 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?

AutomateIT1979 commented 4 years ago

.- When you configure the NTP Servers the primary and secondary NTP Servers are different?

  1. Yes they are different

.- You have at least one NTP Server configured?

.- What shows the file ntp.txt?