File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ function Invoke-AnkaCommand {
6767 [string ] $Command
6868 )
6969
70- $result = bash - c " $Command 2>&1" | Out-String
70+ $result = bash - c " $Command 2>&1"
7171 if ($LASTEXITCODE -ne 0 ) {
7272 Write-Error " There is an error during command execution:`n $result "
7373 exit 1
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ function Invoke-EnableAutoLogon {
4545
4646 $ipAddress = Get-AnkaVMIPAddress - VMName $TemplateName
4747
48+ Wait-AnkaVMSSHService - VMName $TemplateName - Seconds 30
49+
4850 Write-Host " `t [*] Enable AutoLogon"
4951 Enable-AutoLogon - HostName $ipAddress - UserName $TemplateUsername - Password $TemplatePassword
5052
Original file line number Diff line number Diff line change @@ -292,7 +292,12 @@ function Invoke-SSHPassCommand {
292292 " ${env: SSHUSER} @${HostName} "
293293 )
294294 $sshPassOptions = $sshArg -join " "
295- bash - c " $sshPassOptions \"" $Command \"" 2>&1"
295+ $result = bash - c " $sshPassOptions \"" $Command \"" 2>&1"
296+ if ($LASTEXITCODE -ne 0 ) {
297+ Write-Error " There is an error during command execution:`n $result "
298+ exit 1
299+ }
300+ $result
296301}
297302
298303function Invoke-WithRetry {
@@ -330,7 +335,10 @@ function Restart-VMSSH {
330335 [string ] $HostName
331336 )
332337
333- $command = " sudo reboot"
338+ #
339+ # https://unix.stackexchange.com/questions/58271/closing-connection-after-executing-reboot-using-ssh-command
340+ #
341+ $command = ' (sleep 1 && sudo reboot &) && exit'
334342 Invoke-SSHPassCommand - HostName $HostName - Command $command
335343}
336344
You can’t perform that action at this time.
0 commit comments