EvotecIT / Testimo

Testimo is a PowerShell module for running health checks for Active Directory against a bunch of different tests
547 stars 58 forks source link

Time Settings [Fail] [Index operation failed; the array index evaluated to null.] #42

Closed jakobwest closed 5 years ago

jakobwest commented 5 years ago

When running the Time Settings tests against the primary DC in our domain I get the error message:

Time Settings [Fail] [Index operation failed; the array index evaluated to null.]

I found that, under the covers, the command "Get-PSRegistry -ComputerName $_ -RegistryPath "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" is being executed, which, in my case produces the following output:

ServiceDllUnloadOnStop : 1 ServiceMain : SvchostEntry_W32Time NtpServer : 0.us.pool.ntp.org 1.us.pool.ntp.org 2.us.pool.ntp.org 3.us.pool.ntp.org Type : NTP ServiceDll : C:\Windows\system32\w32time.dll ComputerName : dc1

In reviewing the PS code, I'm not sure what the intention is by splitting the $TimeParameters.NtpServer list into the $NtpServers array, and then iterating over that array to split it again? In my case, this definitely doesn't work, and it seems there should be a check of the $NtpServers list before attempting the latter operation.

Any help would be greatly appreciated! Thanks

PrzemyslawKlys commented 5 years ago

Hi, Thank you for reporting this. In your case, the configuration is wrong or at least incomplete.

https://docs.microsoft.com/en-us/windows-server/networking/windows-time-service/windows-time-service-tools-and-settings

image

Each entry in your case should have a comma and after a comma one of 4 values. time.windows.com,0x1 is the default.

Of course, it may be that it works but you're missing interval setting and my code is not checking if split succeeded (to account the interval value) - which is why I need to fix it. But in your case, you should fix it as well.

jakobwest commented 5 years ago

That was it! I adjusted the config on my DC as you suggested, and everything is working now. Thanks for the quick response, and thanks for teaching me something new.

PrzemyslawKlys commented 5 years ago

Great. Thank you. I've actually updated test now:

image

And

PrzemyslawKlys commented 5 years ago

Err:

image

Here's proper test.