Set-ExecutionPolicy Unrestricted
CLS
Import-CSV "d:\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..."
" 192.168.1.1 mojwpis1" | Out-File $hostfile -encoding ASCII -append
" 192.168.1.1 mojwpis2" | Out-File $hostfile -encoding ASCII -append
Write-Host "Done!"
}
Else
{
Write-Host -Fore Red "Can't Access $Server"
}
}
Plik ServersName:
ServerName
Server1
Server2
Brak komentarzy:
Prześlij komentarz