Profiles (essentially "host file fragments") would allow entire blocks of IP addresses to be saved and applied/removed from the system hosts file. Primary use case are swapping entire sets of domains between different environments (or to bypass a load balancer), or simply shipping a set of "dev" host entries along with an application.
Initial thoughts on Cmdlets:
Export-HostsProfile -Hosts @("hosta", "hostb*") -Profile SomeProfileRemove-HostsProfile -Profile SomeProfile - Essentially just Remove-Item on the file
Publish-HostsProfile -Profile SomeProfile - Merges a hosts profile into the hosts file, basically calling Set-HostEntry -Force for each of them.
Unpublish-HostsProfile -Profile SomeProfile - Removes all host entries specified by a profile (no attempt to restore previous values)
(Profile is either a path to a file or potentially just be a name, in which case it will be stored in Documents\PsHosts\Profiles)
It's probably unnecessary for any of these cmdlets to be C#, since they are all wrapping basic functionality around the core hosts cmdlets.
Profiles (essentially "host file fragments") would allow entire blocks of IP addresses to be saved and applied/removed from the system hosts file. Primary use case are swapping entire sets of domains between different environments (or to bypass a load balancer), or simply shipping a set of "dev" host entries along with an application.
Initial thoughts on Cmdlets:
Export-HostsProfile -Hosts @("hosta", "hostb*") -Profile SomeProfile
Remove-HostsProfile -Profile SomeProfile
- Essentially justRemove-Item
on the filePublish-HostsProfile -Profile SomeProfile
- Merges a hosts profile into the hosts file, basically callingSet-HostEntry -Force
for each of them.Unpublish-HostsProfile -Profile SomeProfile
- Removes all host entries specified by a profile (no attempt to restore previous values)(
Profile
is either a path to a file or potentially just be a name, in which case it will be stored inDocuments\PsHosts\Profiles
)It's probably unnecessary for any of these cmdlets to be C#, since they are all wrapping basic functionality around the core hosts cmdlets.