Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Remove-HFMHostsFileEntry #17

Closed
Stephanevg opened this issue Oct 11, 2018 · 2 comments
Closed

Add Remove-HFMHostsFileEntry #17

Stephanevg opened this issue Oct 11, 2018 · 2 comments

Comments

@Stephanevg
Copy link
Owner

Isolating discussion from #4

@LxLeChat It make sense to me to be able to remove an entry. I think we should offer the possibility to to the end user to do it in several ways:

  1. via [HostsEntry] Just like in your example from Make module easier to use: Add powershell Functions  #4 It would make sense, to be able to remove an single or an array of Hostsentry objects from a given Hostsfile
  2. Via String: It would be good to have have the user to write a string, which could be a FQDN or an IP address. In the background, we could handle this using a regex, and according to the type, we will fetch the corresponding entry, and if present, remove it. Perrhaps, this one should also be an array.

These are the cases I could think of

Remove-HFMHostsFileEntry -Entry  "192.168.1.34"
Remove-HFMHostsFileEntry -Entry  "Server01"

# Your example:
$a = Get-HFMHostsFile
$b = Get-HFMHostsFileContent
Remove-HFHMHostsFileEntry -Entry $b[0..5] #remove 6 first entries # Parameters should be singular.

I think this could be managed simply using a switch -Regex
where we will identify if it is IP, FQDN, netbiosName
Alos check if of Type [Entrytype]

`
#PseudoCode:

if($Entry.GetType().FullName -eq "EntryType"){
#Do work
}Else{

Switch($Entry){
     '^\d' {#Ip}
     '^\w' {fqdn or netbios}
    'default' {Throw 'not supported'}
  }

}

`

Somethig like that

@LxLeChat
Copy link
Collaborator

i'll do it :)

@Stephanevg
Copy link
Owner Author

Added in PR #23
Thank you so much @LxLeChat for your awesome work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants