PowerTip: Use PowerShell to Clear the Trusted Hosts File

Doctor Scripto

Summary: Use Windows PowerShell to clear the trusted hosts file.

Hey, Scripting Guy! Question How can I use Windows PowerShell to clear all values from my trusted hosts file?

Hey, Scripting Guy! AnswerThe trusted hosts file is part of the WSMAN configuration, and the easiest way to clear it is to use Clear-Item:

£> Get-Item -Path WSMan:localhostClientTrustedHosts | fl Name, Value

Name  : TrustedHosts

Value : server02,10.10.54.201

£> Clear-Item -Path WSMan:localhostClientTrustedHosts -Force

£> Get-Item -Path WSMan:localhostClientTrustedHosts | fl Name, Value

Name  : TrustedHosts

Value :

Note  If you don’t use the –Force parameter on Clear-Item, you must respond to a message asking you to confirm the action.

0 comments

Discussion is closed.

Feedback usabilla icon