Skip to main content

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

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? 

$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

 


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. 


Reply