{"id":13599291,"url":"https://github.com/Badgerati/PoshHosts","last_synced_at":"2025-04-10T12:32:04.811Z","repository":{"id":146595864,"uuid":"158010281","full_name":"Badgerati/PoshHosts","owner":"Badgerati","description":"Cross-platform module to control the hosts file from the command line","archived":false,"fork":false,"pushed_at":"2019-08-14T13:28:44.000Z","size":55,"stargazers_count":18,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-04-09T02:08:43.925Z","etag":null,"topics":["cross-platform","environments","hosts","hosts-file","hostsfile","ping","powershell","profiles"],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Badgerati.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-11-17T17:55:55.000Z","updated_at":"2025-03-04T14:55:24.000Z","dependencies_parsed_at":"2023-06-25T23:54:37.627Z","dependency_job_id":null,"html_url":"https://github.com/Badgerati/PoshHosts","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badgerati%2FPoshHosts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badgerati%2FPoshHosts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badgerati%2FPoshHosts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Badgerati%2FPoshHosts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Badgerati","download_url":"https://codeload.github.com/Badgerati/PoshHosts/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217131,"owners_count":21066633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-platform","environments","hosts","hosts-file","hostsfile","ping","powershell","profiles"],"created_at":"2024-08-01T17:01:01.820Z","updated_at":"2025-04-10T12:32:03.647Z","avatar_url":"https://github.com/Badgerati.png","language":"PowerShell","funding_links":[],"categories":["PowerShell"],"sub_categories":[],"readme":"# Hosts\n\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/Badgerati/PoshHosts/master/LICENSE.txt)\n[![AppVeyor](https://img.shields.io/appveyor/ci/Badgerati/PoshHosts/master.svg?label=AppVeyor)](https://ci.appveyor.com/project/Badgerati/poshhosts/branch/master)\n[![Travis CI](https://img.shields.io/travis/Badgerati/PoshHosts/master.svg?label=Travis%20CI)](https://travis-ci.org/Badgerati/PoshHosts)\n\n[![PowerShell](https://img.shields.io/powershellgallery/dt/poshhosts.svg?label=PowerShell\u0026colorB=085298)](https://www.powershellgallery.com/packages/PoshHosts)\n\nModule that introduces a new `hosts` command on your terminal, that allows you to control the hosts file from the command line - on Windows, Linux and MacOS.\n\nThe `hosts` commands allows you to add/remove entries; as well enable/disable them. It also supports profiles, so you can have a developer hosts file in your repo and import/merge it for developers.\n\nThe `hosts` command also lets you test entries by pinging them, either using the normal ping or by passing specific ports.\n\n## Features\n\n* Control the hosts file from the command line\n* Support for host profiles, useful for local environments\n* Test entries in a hosts file by pinging them - even with specific ports\n* Display a diff between two host files\n* Support for environment sections in host files\n* Support for RDPing onto servers via host entries\n* Ability to open the hosts file from CLI (notepad on Windows, Vi on Unix)\n\n## Install\n\nYou can install PoshHosts from the PowerShell Gallery:\n\n```powershell\n# powershell gallery\nInstall-Module -Name PoshHosts\n```\n\n## Commands\n\nFormat: `hosts \u003ccommand\u003e [\u003cv1\u003e] [\u003cv2\u003e] [-p \u003chosts-path\u003e] [-e \u003cenvironment\u003e] [-c \u003cpscredentials\u003e]`\n\n* `-v1` and `-v2` supply the main data to commands: such as IP addresses, host names, paths and ports.\n* `-p` allows you to override the default main hosts file path with a custom one.\n* `-e` allows you to control specific environments, such as add an entry or remove all entries for an environment.\n* `-c` allows you to specify credentials - is only used for `rdp` currently\n\n\u003e Actions that alter data in the hosts file will always create a `.bak` first; so if the command fails, then the hosts are restored from this `.bak`. If you mess-up and need to restore, the `.bak` is always left in place, calling `hosts restore` will solve your problems!\n\n```powershell\n# adds new entries\nhosts add 127.0.0.2 dev.test.local\nhosts add 192.168.0.1 build.office, build\nhosts add 10.10.1.3 site.test -e staging\n\n# sets entries, removing any previous settings\nhosts set 127.0.0.3 qa.test.local\nhosts set 10.10.1.2 private.software.live, private.website.live\n\n# removes entries\nhosts remove 127.0.0.2\nhosts remove *.office\nhosts remove 192.168.*, *.local\nhosts remove 192.* -e office\nhosts remove -e dev\n\n# disables an entry (by commenting it out)\nhosts disable dev.test.local\nhosts disable 192.168.*, *.local\nhosts disable *.local -e dev\n\n# enables an entry (by uncommenting it out)\nhosts enable dev.test.local\nhosts enable 192.168.*, *.local\nhosts enable *.local -e dev\n\n# completely clears all entries\nhosts clear\n\n# displays the path to the hosts file\nhosts path\n\n# lists entries\nhosts list\nhosts list *.office\nhosts list 192.168.*, *.local\nhosts list -e live\n\n# tests entries by pinging - can also use specific ports\nhosts test\nhosts test * 443\nhosts test dev.test.local 80, 443\nhosts test * -e dev\nhosts test * 80, 443 -e live\n\n# rdp onto entries\nhosts rdp 10.21.*\nhosts rdp -e test\nhosts rdp qa.test -c (Get-Credential)\n\n# open entries in default browser (default protocol is https)\nhosts browse *.local\nhosts browse qa.test http\nhosts browse -e live\n\n# creates a backup of the hosts file - can also specify custom file path\nhosts backup\nhosts backup ./dev.hosts.bak\n\n# restores the hosts file from the backup - can also specify custom file path\nhosts restore\nhosts restore ./dev.hosts.bak\n\n# exports the hosts file to the specified path - useful for profiles\nhosts export ./dev.profile.hosts\nhosts export ./profile.hosts *.local\nhosts export ./qa.profile.hosts -e qa\n\n# imports a hosts profile, replacing the main hosts file\nhosts import ./dev.profile.hosts\nhosts import ./profile.hosts *.local\nhosts import ./qa.profile.hosts -e qa\n\n# merges the hosts file with host profiles (profile has precendence)\nhosts merge ./dev.profile.hosts\nhosts merge ./dev.profile.hosts, ./qa.profile.hosts\n\n# displays the diff of the hosts file to a hosts profile\nhosts diff ./dev.profile.hosts\n\n# displays the contents of the hosts file on the command line\nhosts show\n\n# open the hosts file for editting\nhosts open\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBadgerati%2FPoshHosts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBadgerati%2FPoshHosts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBadgerati%2FPoshHosts/lists"}