Many of us want to edit hosts file remotlel or easily to fun with others. Here is the trick how to edit it remotely.
Input File: Servers.csv – This file contains server name or IP address. List all addresses you want to add in hosts file.You just have to create this files in any folder and save as Servers.csv
Then Click on Start button and type Windows Powershell and Click on first Result "Windows PowerShell ISE".
Download Text file from here or here
Input File: Servers.csv – This file contains server name or IP address. List all addresses you want to add in hosts file.You just have to create this files in any folder and save as Servers.csv
Then Click on Start button and type Windows Powershell and Click on first Result "Windows PowerShell ISE".
In Power Shell type following script and save as "Edit_Hosts_File.ps1" (Without Quotes).
ScriptOutput – You will see the status update on the screen as displayed in the following screenshot:#www.sivarajan.com #blogs.sivarajan.com #Updating HOSTS file using PowerShell Script CLS Import-CSV "C:\Scripts\Servers.csv" | % { $Server = $_.ServerName $adminpath = Test-Path "\\$Server\admin$" If ($adminpath -eq "True") { $hostfile = "\\$Server\c$\Windows\System32\drivers\etc\hosts" Write-Host –NoNewLine "Updating $Server..." "10.10.10.100`tMyhost" | Out-File $hostfile -encoding ASCII -append Write-Host "Done!" } Else { Write-Host -Fore Red "Can't Access $Server" } }
Download Text file from here or here