Removes entries from the hosts file by hostname.
Remove-HostsEntry [-HostName] <String[]> [-Path <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
You can remove multiple entries or pipe entries into this function.
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
HostName | String[] | The hostname of the hosts entry/entries to remove. |
true | true (ByValue) | |
Path | String | The hosts file to modify. Defaults to the Windows hosts file. |
false | false | (Get-PathToHostsFile) |
WhatIf | SwitchParameter | false | false | ||
Confirm | SwitchParameter | false | false | ||
CommonParameters | This cmdlet supports common parameters. For more information type Get-Help about_CommonParameters . |
Remove-HostsEntry -HostName 'adadvisor.net'
Demonstrates how to remove hosts entry for adadvisor.net
, which you probably don't want to do.
Remove-HostsEntry -HostName 'adadvisor.net','www.adchimp.com'
Demonstrates how to remove multiple hosts entries.
('adadvisor.net','www.adchimp.com') | Remove-HostsEntry
Demonstrates how to pipe hostnames into Remove-HostsEntry
.
Remove-HostsEntry -HostName 'adadvisor.net' -Path 'C:\Projects\Carbon\adblockhosts'
Demonstrates how to work with a file other than Windows' default hosts file.