使用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