I have an array of ntp-server passed at a function to loop through that. This is what happens:
$srvA = @(
'0.at.pool.ntp.org',
'1.at.pool.ntp.org',
'2.at.pool.ntp.org',
'3.at.pool.ntp.org'
)
Function Get-NtpTime {
param($srvList)
$srvList
$nSrv = $srvList.Length
foreach ( $Server in $srvList ) {
$nSrv--
Write-Host $Server $nSrv
}
}
Get-NtpTime $srvA
0.at.pool.ntp.org 1.at.pool.ntp.org 2.at.pool.ntp.org 3.at.pool.ntp.org
0.at.pool.ntp.org 1.at.pool.ntp.org 2.at.pool.ntp.org 3.at.pool.ntp.org 70
As you see $srvList seems to be one sring not an array of strings and
$Server is not a single server but all and the length is 70 not 4.
The definition of the array seems to be incorrect but where why and how?
(I tried version of 1 line-array - no difference)