83 lines
3.4 KiB
HTML
83 lines
3.4 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
|
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<link rel="stylesheet" href="main.css" type="text/css" />
|
|
<link rel="stylesheet" href="blog.css" type="text/css" />
|
|
<link rel="alternate" type="application/rss+xml" title="Subscribe to this page..." href="feed.rss" />
|
|
<title>Manage a hosts file</title>
|
|
</head><body>
|
|
<div id="divbodyholder">
|
|
<div class="headerholder"><div class="header">
|
|
<div id="title">
|
|
<h1 class="nomargin"><a class="ablack" href="http://zigford.org/index.html">zigford.org</a></h1>
|
|
<div id="description"><a href="about.html">About</a><a href="links.html"> | Links</a><a href="scripts.html"> | Scripts</a><br>Sharing linux/windows scripts and tips</br></div>
|
|
</div></div></div>
|
|
<div id="divbody"><div class="content">
|
|
<!-- entry begin -->
|
|
<h3><a class="ablack" href="manage-a-hosts-file.html">
|
|
Manage a hosts file
|
|
</a></h3>
|
|
<!-- bashblog_timestamp: #201809112230.51# -->
|
|
<div class="subtitle">September 11, 2018 —
|
|
Jesse Harris
|
|
</div>
|
|
<!-- text begin -->
|
|
|
|
<p>Most people have long forgotten the lowly <a href="https://en.wikipedia.org/wiki/Hosts_(file)">hosts</a> file, but from time to
|
|
time there is still a need to use it.</p>
|
|
|
|
<p>So I wrote some powershell functions to automate it in a simpler way.</p>
|
|
|
|
<hr />
|
|
|
|
<p>Maybe your on a home network with a router that doesn't have dynamic dns.
|
|
Today I had to resort to editing a hosts file to work around a side effect
|
|
of enabling on-prem single sign-on with ADFS.</p>
|
|
|
|
<p>I won't go into too much detail, but to say that if your on a local network
|
|
with ADFS, but your using a non domain-joined device, your device will be
|
|
redirected to a type of authentication which is incompatible with Windows
|
|
Hello or longform@upn type usernames.</p>
|
|
|
|
<p>The reason this is, is because it uses split DNS to redirect you to the
|
|
appropriate web login on internal vs external.</p>
|
|
|
|
<p>Anywhoo, a quick workaround is to set a static hosts file record, so that
|
|
when your device tries to resolve the hostname, instead of getting one from
|
|
DNS, you can specify and force the external Forms based auth at all times.</p>
|
|
|
|
<p>Normally, I would just edit my Hosts file and be done with it. But I've been
|
|
experimenting with Intune and got a bunch of my collegues onto the same non
|
|
domain-joined setup. With Intune, you can't do a great deal, but you can
|
|
deploy a powershell script.</p>
|
|
|
|
<p>Thus I wrote a couple of functions, <code>Get-HostsRecord</code>, <code>Set-HostsRecord</code>
|
|
and <code>Remove-HostsRecord</code></p>
|
|
|
|
<p>You can <a href="scripts/Hostsfile.ps1.zip">download</a> a zipped copy here if your interested.</p>
|
|
|
|
<p><em>As a side, I wrote it on my Macbook, so it's PSCore/Unix compatible</em></p>
|
|
|
|
<p>Enjoy.</p>
|
|
|
|
<p>Tags: <a href='tag_powershell.html'>powershell</a>, <a href='tag_intune.html'>intune</a>, <a href='tag_hostsfile.html'>hostsfile</a></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- text end -->
|
|
<!-- entry end -->
|
|
</div>
|
|
<div id="footer">© <a href="http://twitter.com/zigford_org">Jesse Harris</a> — <a href="mailto:jesse@zigford.org">jesse@zigford.org</a><br/>
|
|
Generated with <a href="https://github.com/cfenollosa/bashblog">bashblog</a>, a single bash script to easily create blogs like this one</div>
|
|
</div></div>
|
|
</body></html>
|