Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

readme.md

Check out Carbon (http://get-carbon.org/) for a much more capable powershell automation libary.

Install via nuget (http://nuget.org/List/Packages/PSHostsFile). Or run .\build.ps1 and use the PSHostsFile.dll.

Powershell:

import-module .\PSHostsFile.dll
        
get-HostsFileEntry
remove-HostsFileEntry <hostName>
set-HostsFileEntry <hostName> <Address>

C#:

using PSHostsFile;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach (var hostsEntry in HostsFile.Get())
            {
                System.Console.WriteLine("Have host {0} - {1}.", hostsEntry.Hostname, hostsEntry.Address);
            }

            HostsFile.Set("foo.example.com", "127.0.0.1");  //  Add or update the hosts file entry for foo.example.com
            HostsFile.Set("another.example.com", "127.0.0.1");
            HostsFile.Remove("another.example.com");  //  Remove a hosts file entry
        }
    }
}

About

Change your window's hosts file from C# or Powershell.

Resources

License

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.