- $IP_URL = "127.0.0.1 www.bing.com"
-
- if ((Get-Content $env:windir\System32\drivers\etc\hosts | ?{ $_ -match "$($IP_URL -replace '\s+','\s+')" }) -eq $null)
- {
- "$IP_URL" | ac "$env:windir\System32\drivers\etc\hosts"
- echo "已添加!"
- }
- else
- {
- echo "已存在"
- }
复制代码
|