< Back

Remove-HFMHostsFileEntry

Tue Jan 14, 2020 1:38 am

NAME Remove-HFMHostsFileEntry



SYNOPSIS

Remove entry/entries from a Hosts File





SYNTAX

Remove-HFMHostsFileEntry [-Path] <HostsFile[]> [-Entry] <Object[]> [<CommonParameters>]





DESCRIPTION

Remove entry/entries from a Hosts File





PARAMETERS

-Path <HostsFile[]>



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



-Entry <Object[]>

Accepte string ou [HostEntry]



Required? true

Position? 2

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

You must provide a valid path of type [HostsFile] and an entry of type [HostsEntry] or a [String] representing an

ipaddress or a comment.





OUTPUTS

-





NOTES





This cmdlet uses Class.HostsManagement classes, by @StephaneVG

Fork and star his project if you like it: https://github.com/Stephanevg/Class.HostsManagement

Visit his site, and read his article a boute pratical use of PowerShell Classes:

http://powershelldistrict.com/powershell-class/



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-HFMHostsFile | Remove-HFMHostsFileEntry -Entry "#5.0.0.0"



Will remove any Comment line with ip 5.0.0.0









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>$a = Get-HFMHostsFile



PS C:\\> $b = New-HFMHostsFileEntry -IpAddress "20.0.0.0" -EntryType Entry

PS C:\\> Remove-HFMHostsFileEntry -Path $a -Entry $b

Will remove any Entry line With IpAdress starting with 20.0.0.0









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Get-HFMHostsFile | Remove-HFMHostsFileEntry -Entry "#5.0.0.0","20.0.0.0"



Will remove any Comment line wich start with commented ipadress #5.0.0.0 or 20.0.0.0











RELATED LINKS