< Back
Add-GCHostsFileEntry
Post
NAME Add-GCHostsFileEntry
SYNOPSIS
Adds an entry to the hosts file.
SYNTAX
Add-GCHostsFileEntry [-IPAddress] <String> [-HostName] <String[]> [[-Comment] <String>] [<CommonParameters>]
Add-GCHostsFileEntry [[-InputObject] <PSObject[]>] [<CommonParameters>]
Add-GCHostsFileEntry -LineComment <String> [<CommonParameters>]
DESCRIPTION
Adds an entry to the bottom of the hosts file based
on the supplied host IP address, name(s), and comment.
If an entry that matches both the host name and
IP address already exists, the change will be ignored.
Type 'Get-Help Add-GCHostsFileEntry -Online' for extra information.
PARAMETERS
-InputObject <PSObject[]>
A PSCustomObject with the details of the hosts file entry.
The schema of the object will be as follows:
[PSCustomObject]@{
IPAddress=[IPAddress];
HostNames=[String[]];
Comment=[String];
}
A single PSCustomObject or an array of PSCustomObjects can be
passed in for addition to the hosts file.
Required? false
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
-IPAddress <String>
The IP address to assign to the host name.
This can be an IPv4 or IPv6 address.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-HostName <String[]>
The name of the host to assign the IP address to.
This can be a fully qualified name such as server1.domain.com, or a flat name.
An array of names is supported.
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Comment <String>
Adds a comment on the same line as the IPAddress and HostName pair.
There is no need to supply the '#' character.
Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-LineComment <String>
Inserts a full line comment into the bottom of the hosts file.
There is no need to supply the '#' character.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
System.String
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>The following example adds a host entry to the hosts file:
Add-GCHostsFileEntry -IPAddress 1.2.3.4 -HostName 'server1.company.com'
RELATED LINKS
SYNOPSIS
Adds an entry to the hosts file.
SYNTAX
Add-GCHostsFileEntry [-IPAddress] <String> [-HostName] <String[]> [[-Comment] <String>] [<CommonParameters>]
Add-GCHostsFileEntry [[-InputObject] <PSObject[]>] [<CommonParameters>]
Add-GCHostsFileEntry -LineComment <String> [<CommonParameters>]
DESCRIPTION
Adds an entry to the bottom of the hosts file based
on the supplied host IP address, name(s), and comment.
If an entry that matches both the host name and
IP address already exists, the change will be ignored.
Type 'Get-Help Add-GCHostsFileEntry -Online' for extra information.
PARAMETERS
-InputObject <PSObject[]>
A PSCustomObject with the details of the hosts file entry.
The schema of the object will be as follows:
[PSCustomObject]@{
IPAddress=[IPAddress];
HostNames=[String[]];
Comment=[String];
}
A single PSCustomObject or an array of PSCustomObjects can be
passed in for addition to the hosts file.
Required? false
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
-IPAddress <String>
The IP address to assign to the host name.
This can be an IPv4 or IPv6 address.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-HostName <String[]>
The name of the host to assign the IP address to.
This can be a fully qualified name such as server1.domain.com, or a flat name.
An array of names is supported.
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Comment <String>
Adds a comment on the same line as the IPAddress and HostName pair.
There is no need to supply the '#' character.
Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-LineComment <String>
Inserts a full line comment into the bottom of the hosts file.
There is no need to supply the '#' character.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
System.String
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>The following example adds a host entry to the hosts file:
Add-GCHostsFileEntry -IPAddress 1.2.3.4 -HostName 'server1.company.com'
RELATED LINKS