如何使用PowerShell修改Host文件

下面的命令, 为Host文件添加了一条记录, 让/sps2010/hostheader1/这个url指向server自己.

$url=”http://sps2010/hostheader1/”

if( (Get-Content $env:windir\System32\drivers\etc\hosts |?{$_ -imatch "\s$url"}) -eq $null){"`n127.0.0.1 $url" | Out-File -FilePath "$env:windir\System32\drivers\etc\hosts" -Append -encoding ascii}

参考资料

===============

SharePoint 2010 for Hosters Whitepaper

原文地址:https://www.cnblogs.com/awpatp/p/2329543.html