Reset-HostsFile

Removes all custom host entries from this computer's hosts file.

Syntax

Reset-HostsFile [[-Path] <String>] [-WhatIf] [-Confirm] [<CommonParameters>]

Description

Sometimes you want to start over. This method removes all hosts entries from your hosts file after the default localhost entry.

By default, the current computer's hosts file is reset. You can operate on a custom hosts file by passing its path to the Path argument.

Parameters

Name Type Description Required? Pipeline Input Default Value
Path String

The path to the hosts file to modify. Defaults to the local computer's 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.

EXAMPLE 1

Reset-HostsFile

If your hosts file contains something like this:

127.0.0.1        localhost
10.1.2.3         myserver
10.5.6.7         myserver2

After calling Reset-HostsFile, your hosts will contain:

127.0.0.1        localhost

EXAMPLE 2

Reset-HostsFile -Path my\custom\hosts

Resets the hosts file at my\custom\hosts.