I'm writing a small script that needs at one point to connect to a machine that is not a domain member. The machine the script is run from will always be a domain member.
I've found that using the following works
cd WSMan:\localhost\Client
Set-Item .\TrustedHosts -Value "*" -Force
but I'm looking for an alternative because to use the above commands powershell has to be "run as administrator" and it is only effective during that PS session.
Changing trustedhosts requires local admin priveliges (and is a one-time operation), but the subsequent connection(s) to the non-domain computer do not.