lunes, 16 de junio de 2025

Add entries to a hosts file by powershell

 The follow script tests and adds is it's needed a line to a local host files:

If ((Get-Content "$($env:windir)\system32\Drivers\etc\hosts" ) -notcontains "10.0.0.20 entry.domain.local")  

 {ac -Encoding UTF8  "$($env:windir)\system32\Drivers\etc\hosts" "10.0.0.20 entry.domain.local")   }