Change SSH container to use SSH remoting

This commit is contained in:
Marcos Lilljedahl
2017-09-04 17:33:21 -03:00
parent 6a8c3df9f6
commit f3307d964c
3 changed files with 38 additions and 3 deletions

26
connect.ps1 Normal file
View File

@@ -0,0 +1,26 @@
Param(
[Parameter(Mandatory=$True)]
[string]$endpoint
)
function RegisterEvent {
if ($event) {
Unregister-Event $event
}
($global:event = Register-ObjectEvent -InputObject $session.Runspace -EventName AvailabilityChanged -Action {
if ($session.State -eq "Broken") {
$global:session = New-PSSession -HostName $endpoint -UserName Administrator
RegisterEvent
}
if ($Host.Runspace -ne $session.Runspace) {
Enter-PSSession $session
}
}) | Out-Null
}
$global:session = New-PSSession -HostName $endpoint -UserName Administrator
Enter-PSSession $session
RegisterEvent