💾 Archived View for zigford.org › manage-a-hosts-file.gmi captured on 2024-02-05 at 09:41:13. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-03-20)

-=-=-=-=-=-=-

about

links

scripts

Sharing linux/windows scripts and tips

Manage a hosts file

September 11, 2018 — Jesse Harris

Most people have long forgotten the lowly hosts file, but from time to time there is still a need to use it.

hosts

So I wrote some powershell functions to automate it in a simpler way.

~~~

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.

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.

The reason this is, is because it uses split DNS to redirect you to the appropriate web login on internal vs external.

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.

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.

Thus I wrote a couple of functions, Get-HostsRecord, Set-HostsRecord and Remove-HostsRecord

You can download a zipped copy here if your interested.

download

As a side, I wrote it on my Macbook, so it's PSCore/Unix compatible

Enjoy.

Tags:

powershell

intune

hostsfile

© Jesse Harris

mailto:jesse@zigford.org

Generated with bashblog, a single bash script to easily create blogs like this one

bashblog