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.