stephanevg / hostsfilemanagement Goto Github PK
View Code? Open in Web Editor NEWHosts file management on Windows systems using PowerShell classes
Hosts file management on Windows systems using PowerShell classes
depends on #18
Issue is part of: #6
Generate documentation based on comment based help using PlattyPS.
The documents will then be made available through Github Wiki.
Technical details:
I got this:
> Get-HFMHostsfile | Save-HFMHostFile -BackupFolder C:\admin\backup\
Get-ChildItem : Cannot find path 'C:\admin\backup\' because it does not exist.
At C:\Users\taavast3\OneDrive\Repo\Projects\OpenSource\Class.HostsManagement\HostsFileManagement\Classes\public\HostsFile.ps1:131 char:22
+ ... ckupItems = Get-ChildItem -Path $BackupFolder.FullName -Filter "*$($T ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\admin\backup\:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
WARNING: Could not find a part of the path 'C:\admin\backup\20181118-105624_U279610_Hosts.bak'.
Would make sense to force the creation of the full path if it doesn't exists.
Originally, this repository was built to work with Classes only.
once #4 is resolved, we will need to update the help files. this will result in changing the following things:
Perhaps we can already start to implement some of these things (like the automation using PlatyPS, and creating the WikiPage).
If stumbled on an invalid IP Address do you want it to stop or continue?
This was one of quirks Tobias talked about... ๐
Here's something to think about:
Class parseIPAddress{
$IPAddress
parseIPAddress($ipv4){
$this.IPAddress = ($ipv4 -as [IPAddress]).IPAddressToString
}
}
[parseIPAddress]::new('38.25.63.10')
[parseIPAddress]::new('380.25.63.10')
Class parseIPAddressThrow{
$IPAddress
parseIPAddressThrow($ipv4){
$this.IPAddress = ([IPAddress]$ipv4).IPAddressToString
}
}
[parseIPAddressThrow]::new('38.25.63.10')
[parseIPAddressThrow]::new('380.25.63.10')
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:
Hostsentry
objects from a given HostsfileThese 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
Implement Appvyeor CI
This module is classes based. With experience, I noticed that end users don't really embrace using classes that much, and are more willing to work with functions / cmdlets, thing they are used too since a few years already.
In order to make this module easier for the public embrace, and to abstract the complexity for the end users, and add an encapsulation layer, I would like to add the following cmdlets / functions (See below)
Each cmdlet should have the following:
Please fork, and create an individual branch per function.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.