header image

Clear the trusted host list

Posted by: | December 31, 2019 Comments Off on Clear the trusted host list |

The final option in administering the trusted host list is to clear the entire list. The following function will clear the trusted host list

function clear-trustedhost {
[CmdletBinding()]
param (
[string]$computername = $env:COMPUTERNAME
)

if (Test-Connection -ComputerName $computername -Quiet -Count 1) {
Set-WSManInstance -ResourceURI winrm/config/client -ComputerName $computername -ValueSet @{TrustedHosts = “”}
}
else {
Write-Warning -Message “$computername is unreachable”
}

}

 

Use Set-WSMANinstance to set the value of trusted hosts to being an empty string.

under: PowerShell

Comments are closed.

Categories