Powershell to manipulate host file

后端 未结 9 1703
我在风中等你
我在风中等你 2021-01-30 02:32

I am looking at to see if I can create powershell script to update the contents in the host file.

Anybody know if there are any examples that manipulate the host file u

9条回答
  •  有刺的猬
    2021-01-30 02:50

    All of these answers are pretty elaborate. This is all you need to add a hosts file entry:

    Add-Content -Path C:\Windows\System32\drivers\etc\hosts -Value "127.0.0.1`tlocalhost" -Force
    

    IP address and hostname are separated by `t which is the powershell notation for a tab character.

提交回复
热议问题