Skip to content

Commit 67596c7

Browse files
authored
Update TrustedHosts setting with ToString method (#531)
We noticed a cast exception in our tests -> Cannot convert 'System.Object[]' to the type 'System.String' required by the parameter. Specified method is not supported. # Change type - [x] Bug fix (non-breaking change) # Checklist: - [x] My code follows the style and contribution guidelines of this project. - [x] I have tested and validated my code changes.
1 parent 4a56513 commit 67596c7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/modules/SdnDiag.Utilities.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,7 @@ function New-PSRemotingSession {
18971897
$trustedHosts = Get-Item -Path "WSMan:\localhost\client\TrustedHosts"
18981898
if ($trustedHosts.Value -notlike "*$objectName*" -and $trustedHosts.Value -ne "*") {
18991899
"Adding {0} to {1}" -f $objectName, $trustedHosts.PSPath | Trace-Output
1900-
Set-Item -Path "WSMan:\localhost\client\TrustedHosts" -Value $objectName -Concatenate
1900+
Set-Item -Path "WSMan:\localhost\client\TrustedHosts" -Value $objectName.ToString() -Concatenate -Force
19011901
}
19021902
}
19031903
catch {

0 commit comments

Comments
 (0)