Get-PathToHostsFile

Gets the path to this computer's hosts file.

Syntax

Get-PathToHostsFile [<CommonParameters>]

Description

This is a convenience method so you don't have to have the path to the hosts file hard-coded in your scripts.

EXAMPLE 1

Get-PathToHostsFile

Returns C:\Windows\system32\drivers\etc\hosts. Uses the environment variable to find the root to the Windows directory.