使用PowerShell 修改hosts


直接上代码

# author:lttr <www.cnblogs.com/GoCircle> 
# date:2019-08-09
[CmdletBinding()] param ( [Parameter(Mandatory
=$true,Position=0)][string]$IPURL ) if((Get-Content $env:windir\System32\drivers\etc\hosts |?{$_ -match "/s$IPURL"}) -eq $null){ "`n$IPURL" | Out-File -FilePath "$env:windir\System32\drivers\etc\hosts" -Append -encoding ascii Write-Host "修改成功!" }else{ Write-Host "host文件中存在该配置信息。" }

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM