AutomoxAutomox

Change hosts file on Windows Computer

mikesid
December 7, 2022 at 3:53 pm UTC
#Windows#Worklets

I’m trying to find a way to change the hosts file on Windows PC’s using automox. Would anyone know of a way to do this?

 

Thank you,

 

MIKE

This discussion is archived and closed to replies. Continue it in the Automox Community Slack.

Discuss on Slack

Replies (2)

mikesidDecember 8, 2022
#1

I got the below code to work on my local PC. How would i be able to make a worklet with this code? Does automox run this code as admin or something with high enough privs to make the changes? 

powershell32 lines
$file = "C:\Windows\System32\drivers\etc\hosts"

$hostfile = Get-Content $file

$hostfile += "0.0.0.0	login.yahoo.com"
$hostfile += "0.0.0.0	login.aol.com"
$hostfile += "0.0.0.0	www.icloud.com"
$hostfile += "0.0.0.0	fastmail.com"
$hostfile += "0.0.0.0	proton.me"
$hostfile += "0.0.0.0	hushmail.com"
$hostfile += "0.0.0.0	mail.yahoo.com"
$hostfile += "0.0.0.0	mail.aol.com"
$hostfile += "0.0.0.0	gandi.net"
$hostfile += "0.0.0.0	www.hey.com"
$hostfile += "0.0.0.0	kolabnow.com"
$hostfile += "0.0.0.0	www.lycos.com"
$hostfile += "0.0.0.0	mail.com"
$hostfile += "0.0.0.0	mail.ru"
$hostfile += "0.0.0.0	mailfence.com"
$hostfile += "0.0.0.0	posteo.de"
$hostfile += "0.0.0.0	rackspace.com"
$hostfile += "0.0.0.0	comcast.net"
$hostfile += "0.0.0.0	more.att.com"
$hostfile += "0.0.0.0	login.xfinity.com"
$hostfile += "0.0.0.0	www.rediff.com"
$hostfile += "0.0.0.0	ya.ru"
$hostfile += "0.0.0.0	yandex.com"
$hostfile += "0.0.0.0	mail.google.com"
$hostfile += "0.0.0.0	drive.google.com"
$hostfile += "0.0.0.0	login.live.com"

Set-Content -Path $file -Value $hostfile -Force

 

mikesidDecember 8, 2022
#2

I think i got it. added it as a software worklet then added the code to evaluation and remediation, saved it and ran it. looks good.