November 29th, 2013

PowerTip: Use PowerShell to Clear the Trusted Hosts File

Doctor Scripto
Scripter

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.

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.