Trustedhosts pukes on lines longer than 1023 characters, and I just parse this limit. I encoded a small small FILO queue to make sure that I can always add a new host when necessary, and only omit my least used servers when I found this weirdness. I cured him before I lost all my hair, so good. I do not understand why this is happening.
$namesString = 'server1.there.com,server2.there.com,server3.there.com'
Write-Host ("So, we have a nice little list of servers. Let trust them.")
Set-Item wsman:localhost\client\trustedhosts -Value $namesString -Force
Write-Host ("They're nicely trusted now")
if ($namesString.length -gt 1) {
Write-Host ("Now we know it longish")
}
Write-Host ("OK. Let try trusting the same string.")
Write-Host ("(By the way, it a $($namesString.getType()))")
Write-Host ("(and let check whether it an array: $($namesString -is [array]))")
Set-Item wsman:localhost\client\trustedhosts -Value $namesString -Force
Write-Host ("Why did testing the length of the string cause this confirmed and tested string to report as an object array?")
Next release results
So, we have a nice little list of servers. Let trust them.
They're nicely trusted now
Now we know it longish
OK. Let try trusting the same string.
(By the way, it a string)
(and let check whether it an array: False)
Set-Item : Cannot convert 'System.Object[]' to the type 'System.String' required by the parameter. Specified method is not sup
ported.
At C:\Users\...\AppData\Local\Temp\2\07da58ce-2578-4603-8291-83e1cc231522.ps1:11 char:9
+ Set-Item <<<< wsman:localhost\client\trustedhosts -Value $namesString -Force
+ CategoryInfo : NotSpecified: (:) [Set-Item], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.SetItemCommand
Why did testing the length of the string cause this confirmed and tested string to report as an object array?
2000 , 3 . , wsman . , , , , , - -.