< Back
Remove-TecBoxHostnames
Post
NAME Remove-TecBoxHostnames
SYNOPSIS
Removes one or more hostnames from the hosts file.
SYNTAX
Remove-TecBoxHostnames [-Hostnames] <String[]> [[-RetryCount] <Int32>] [<CommonParameters>]
DESCRIPTION
The hosts file is used to map hostnames to IP addresses.
PARAMETERS
-Hostnames <String[]>
One or more hostnames to remove from the hosts file.
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-RetryCount <Int32>
How many times to try writing to the hosts file before giving up? Defaults to 30.
IMPORTANT: It's advised to retry as many times as possible to avoid
transient locks on the hosts file causing a failure.
Required? false
Position? 2
Default value 30
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
NOTES
This script must be run with administrator privileges.
CRITICAL: The consequence of a failure is the hosts file will be left empty.
TODO: Improvement robustness to prevent a failure resulting in an empty hosts file
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Remove-TecBoxHostnames foobar
Description
-----------
Assume the following line was previously added to the hosts file:
127.0.0.1 foobar
After running "Remove-TecBoxHostnames foobar" the hosts file no longer contains this
line.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Remove-TecBoxHostnames foo
Description
-----------
Assume the following line was previously added to the hosts file:
127.0.0.1 foobar foo bar
After running "Remove-TecBoxHostnames foo" the line in the hosts file is updated
to remove the specified hostname ("foo"):
127.0.0.1 foobar bar
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Remove-TecBoxTecBoxHostnames foo, bar
Description
-----------
Assume the following line was previously added to the hosts file:
127.0.0.1 foobar foo bar
After running "Remove-TecBoxHostnames foo, bar" the line in the hosts file is updated to
remove the specified hostnames ("foo" and "bar"):
127.0.0.1 foobar
RELATED LINKS
SYNOPSIS
Removes one or more hostnames from the hosts file.
SYNTAX
Remove-TecBoxHostnames [-Hostnames] <String[]> [[-RetryCount] <Int32>] [<CommonParameters>]
DESCRIPTION
The hosts file is used to map hostnames to IP addresses.
PARAMETERS
-Hostnames <String[]>
One or more hostnames to remove from the hosts file.
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-RetryCount <Int32>
How many times to try writing to the hosts file before giving up? Defaults to 30.
IMPORTANT: It's advised to retry as many times as possible to avoid
transient locks on the hosts file causing a failure.
Required? false
Position? 2
Default value 30
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
NOTES
This script must be run with administrator privileges.
CRITICAL: The consequence of a failure is the hosts file will be left empty.
TODO: Improvement robustness to prevent a failure resulting in an empty hosts file
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Remove-TecBoxHostnames foobar
Description
-----------
Assume the following line was previously added to the hosts file:
127.0.0.1 foobar
After running "Remove-TecBoxHostnames foobar" the hosts file no longer contains this
line.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Remove-TecBoxHostnames foo
Description
-----------
Assume the following line was previously added to the hosts file:
127.0.0.1 foobar foo bar
After running "Remove-TecBoxHostnames foo" the line in the hosts file is updated
to remove the specified hostname ("foo"):
127.0.0.1 foobar bar
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Remove-TecBoxTecBoxHostnames foo, bar
Description
-----------
Assume the following line was previously added to the hosts file:
127.0.0.1 foobar foo bar
After running "Remove-TecBoxHostnames foo, bar" the line in the hosts file is updated to
remove the specified hostnames ("foo" and "bar"):
127.0.0.1 foobar
RELATED LINKS