# Get current TrustedHosts value $current = (Get-Item WSMan:\localhost\Client\TrustedHosts).Value # Add new host, keeping any existing entries $new = "$current,192.168.3.166" # Remove any accidental double commas or leading/trailing commas $new = ($new -split ',' | Where-Object { $_ -and $_ -ne '' } | Select-Object -Unique) -join ',' # Set TrustedHosts with the combined list Set-Item WSMan:\localhost\Client\TrustedHosts -Value $new