PowerTip: Use PowerShell to Clear the Trusted Hosts File

PowerTip: Use PowerShell to Clear the Trusted Hosts File

  • Comments 1
  • Likes

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:\localhost\Client\TrustedHosts | fl Name, Value

Name  : TrustedHosts

Value : server02,10.10.54.201

£> Clear-Item -Path WSMan:\localhost\Client\TrustedHosts -Force

£> Get-Item -Path WSMan:\localhost\Client\TrustedHosts | 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.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Thank you that was very helpful