All Projects → Stephanevg → HostsFileManagement

Stephanevg / HostsFileManagement

Licence: other
Hosts file management on Windows systems using PowerShell classes

Programming Languages

powershell
5483 projects

Projects that are alternatives of or similar to HostsFileManagement

openmoji-awesome
CSS classes to easily integrate Openmoji in your website!
Stars: ✭ 19 (-24%)
Mutual labels:  classes
tailwind-cascade
Override TailwindCSS classes for component composition
Stars: ✭ 28 (+12%)
Mutual labels:  classes
htmlhost
hostHTML.live is downright the fastest way of hosting your single page HTML!
Stars: ✭ 21 (-16%)
Mutual labels:  hostsfile
ta-json
Type-aware JSON serializer/parser
Stars: ✭ 67 (+168%)
Mutual labels:  classes
postcss-typed-css-classes
PostCSS plugin that generates typed entities from CSS classes for chosen programming language.
Stars: ✭ 12 (-52%)
Mutual labels:  classes
MulleObjC
💎 A collection of Objective-C root classes for mulle-objc
Stars: ✭ 50 (+100%)
Mutual labels:  classes
react-native-use-styles
A classy approach to manage your react native styles.
Stars: ✭ 66 (+164%)
Mutual labels:  classes
PowerVCF
PowerVCF: A PowerShell Module for VMware Cloud Foundation
Stars: ✭ 25 (+0%)
Mutual labels:  powershell-module
The-Java-Workshop
A New, Interactive Approach to Learning Java
Stars: ✭ 65 (+160%)
Mutual labels:  classes
PowerFGT
PowerShell module to manage Fortinet (FortiGate) Firewall
Stars: ✭ 80 (+220%)
Mutual labels:  powershell-module
Heir
Helper functions for prototypical inheritance in JavaScript
Stars: ✭ 61 (+144%)
Mutual labels:  classes
claxed
Classes with the same style of Styled-Components
Stars: ✭ 17 (-32%)
Mutual labels:  classes
OutSystems.SetupTools
Powershell module to install and manage the OutSystems platform
Stars: ✭ 20 (-20%)
Mutual labels:  powershell-module
spruceup
Spruce up CSS classes
Stars: ✭ 12 (-52%)
Mutual labels:  classes
Sorlov.PowerShell
This is the public version of Sorlov.PowerShell Self-Hosted Executable Extensions for Powershell
Stars: ✭ 22 (-12%)
Mutual labels:  powershell-module
SoftUni-Software-Engineering
SoftUni- Software Engineering
Stars: ✭ 47 (+88%)
Mutual labels:  classes
Attrs
Python Classes Without Boilerplate
Stars: ✭ 3,786 (+15044%)
Mutual labels:  classes
PSPasswordExpiryNotifications
Following PowerShell Module provides different approach to scheduling password notifications for expiring Active Directory based accounts. While most of the scripts require knowledge on HTML... this one is just one config file and a bit of tingling around with texts. Whether this is good or bad it's up to you to decide. I do plan to add an optio…
Stars: ✭ 38 (+52%)
Mutual labels:  powershell-module
lua-classy
Class-based OO library for Lua
Stars: ✭ 28 (+12%)
Mutual labels:  classes
PSRule.Rules.CAF
A suite of rules to validate Azure resources against the Cloud Adoption Framework (CAF) using PSRule.
Stars: ✭ 54 (+116%)
Mutual labels:  powershell-module

Manage local and remote Hosts file(s) using Powershell.

This modules helps to read, parse, save, edit, and backup your local or remote HOSTS file. The main advantage of this module is that it converts the HOSTS file into a rich object.

It becomes easy to filter a HOSTS file to find entries that are double, incorrect, or that need to be deleted. New entries can easily be added as well. Alll this at scale, on hundred machines from your network at once, from one single locatino.

Getting Started

getting and analyzing Hosts file information

The following command will list the content of the local hosts file

 Get-HFMHostsfile | Get-HFMHostsFileContent

###How to get Hosts File information from a remote computer?

Get-HFMHostsfile -ComputerName $RemoteComputerName | Get-HFMHostsFileContent | ft -AutoSize

Understanding the data:

Adding data

First, get a reference to the HostsFile you would like to manipulate:

$HostsFile = Get-HFMHostsfile # Gets the local hostsfile .
$NewEntry = New-HFMHostsFileEntry -IpAddress "10.20.30.40" -HostName "StephaneVG" -FullyQualifiedName "Stephane.v.g" -Description "My machine" -EntryType Entry

Looking in the $NewEntry variable, a new HostsFile entry is prepared:

>  $NewEntry


Ipaddress          : 10.20.30.40
HostName           : StephaneVG
FullQuallifiedName : Stephane.v.g
Description        : My machine
EntryType          : Entry

Now that we hold a reference to our HostsFile where we want to add the data ($HostsFile) and a reference to the data we actually want to add ($NewEntry) we can add the data using the following line:

Set-HFMHostsFileEntry -Path $HostsFile -Entries $NewEntry

Looking in the hostsfile, there will be a new line:

10.20.30.40		StephaneVG		Stephane.v.g		# My machine

Backup mechanism

The HostsFile is a crucial component for a system that cannot rely on DNS. Messing up the HostsFile can have some serious consequences on the ability to reach other members of the network. Therefor, each time Set-HFMHostsEntry is called a backup of the hosts file is automatically done. The backup is located in the same folder as the HostsFile. Here under is the file generated by our previous command:

20181118-104429_Hosts.bak

The mechanism goes up until 5 backups max. After that, it will delete the oldest one in order to be able to add a more recent one.

Trigger a backup

Sometimes, one doesn't want to wait until the we change something to the hosts file in order to trigger a backup. Scheduling backups of local hosts and saving them to a central location is possible using the Save-HFMHostsFile cmdlet.

Get-FHMHostsFile | Save-HFMHostFile -BackupFolder \\Server01\HostsFileBackups\

Read my blog post about implementation details:

If you are interested in the details of this module, want to learn about it's history, and improve your knowledge about powershell classes, I have writen an extensive documentation on my blog. You can find it on PowerShellDistrict-ManagingHostsFile


Contributing

For the ones that would like to contribute, it is possbile to find technical details on the implementation of the module here

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].