Skip to main content

[ARCHIWUM] Zmiana pliku host, na potrzeby połączenia się do WINRM poprzez inny adres IP do danego hosta

Strona zarchiwizowana. Treść została rozbudowana i przeniesiona. Aktualna wersja: WinRM — zarządzanie zdalne. Ta strona zostaje wyłącznie dla historii.


Uruchamiamy powershell jako administrator

get-content 'C:\Windows\System32\drivers\etc\hosts'
$h='C:\Windows\System32\drivers\etc\hosts'; $wpis='ADRES-IP NAZWA-DNS'
Copy-Item $h "$h.bak" -Force
try {
    Add-Content $h "`n$wpis" -Encoding ASCII
    Clear-DnsClientCache
    $s = New-PSSession -ComputerName ft-n045.foolstheory.local -Credential $c -ErrorAction Stop
}
finally {
    Copy-Item "$h.bak" $h -Force
    Clear-DnsClientCache
}
Enter-PSSession -Session $s