Newbie WS-management error

WS-management error
set:item the WS-managment services cannot process the configuration request. The xml contains an invalid setting. the value is longer than the maximum length or 10239.
it references this line…
Set-Item WSMan:\localhost\Client\TrustedHosts -Value “$Computer” -Concatenate -Force.

CatagoryInfo: not spcecified: (:slight_smile: [Set-item], InvalidOperationException

does the trustedhosts file have a size limitation?

the PC running the script is (Win10 v1709) in a domain environment.
PSversion 5.1
the script loops though txt file containing ComputerNames to get system info from remote win 7 PC’s

the script still runs and the output is correct
any thoughts would be greatly appreciated

thanks in advance

Are you adding each host found in the loop to TrustedHosts? I would suggest not doing that and using a single wild card in TrustedHosts for the domain as in *

Hi tonyd,
thank you for your reply.
yes, the set-Item wsman:… is at the start of a foreach loop.
I will give wild carding the domain ago.
is replacing $computer with * likely to solve the error i’m getting, or just improve the code?
thanks again

My belief is that your error shows there is a size limit to the TrustedHost back end XML file and that yes, this will also solve the error. However, I am not an expert in the backend XML for trusted hosts, this is the first I have heard of that. But I do believe this will solve the error as well.