Script for Host entry in remote servers
#Host entry script by Suresh
## Input the server list in below path
$servers= Get-Content "C:\Users\u-07-adm-ad-08\Desktop\Servers.txt"
foreach ($server in $servers)
{
$adminpath = Test-Path "\\$Server\admin$"
If ($adminpath -eq "True")
{
$hostfile = "\\$Server\c$\Windows\System32\drivers\etc\hosts"
Write-Host –NoNewLine "Updating $Server..."
#Add host entries below that need to be added on remote servers
"104.108.176.95 www.identityiq.philips.com" | Out-File $hostfile -encoding ASCII -append
"23.38.37.249 www.egrc.philips.com" | Out-File $hostfile -encoding ASCII -append
Write-Host "Done!"
}
Else
{
Write-Host -Fore Red "Can't Access $Server"
}
}
## Input the server list in below path
$servers= Get-Content "C:\Users\u-07-adm-ad-08\Desktop\Servers.txt"
foreach ($server in $servers)
{
$adminpath = Test-Path "\\$Server\admin$"
If ($adminpath -eq "True")
{
$hostfile = "\\$Server\c$\Windows\System32\drivers\etc\hosts"
Write-Host –NoNewLine "Updating $Server..."
#Add host entries below that need to be added on remote servers
"104.108.176.95 www.identityiq.philips.com" | Out-File $hostfile -encoding ASCII -append
"23.38.37.249 www.egrc.philips.com" | Out-File $hostfile -encoding ASCII -append
Write-Host "Done!"
}
Else
{
Write-Host -Fore Red "Can't Access $Server"
}
}
Comments
Post a Comment