File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed
ci/tasks/install-windows-updates Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -81,13 +81,26 @@ function wait_for_vm_to_come_up() {
8181}
8282
8383function get_windows_updates_remaining() {
84- echo " Checking for updates remaining (via exit code of 'guest.run')..." >&2
85-
86- govc guest.run \
87- -vm.ipath=" ${vm_ipath} " \
88- -l=" ${vm_username} :${vm_password} " \
89- " ${powershell_exe} " \
90- " (Get-WindowsUpdate).Count"
84+ echo " Checking for updates remaining (via exit code of 'guest.ps')..." >&2
85+ # run powershell command that "exits" with the Count returned by Get-WindowsUpdate
86+ get_update_count_pid=" $( start_powershell_command " exit (([array](Get-WindowsUpdate)).Count)" ) "
87+
88+ exit_code=$( get_powershell_pid_exit_code " ${get_update_count_pid} " )
89+ echo " Checking for updates remaining (via exit code of 'guest.ps') returned '${exit_code} '" >&2
90+
91+ if [[ " ${exit_code} " == " null" ]]; then
92+ echo " Checking for updates remaining (via 'guest.run')..." >&2
93+ exit_code=$(
94+ govc guest.run \
95+ -vm.ipath=" ${vm_ipath} " \
96+ -l=" ${vm_username} :${vm_password} " \
97+ " ${powershell_exe} " \
98+ " (Get-WindowsUpdate).Count"
99+ )
100+ echo " Checking for updates remaining (via 'guest.run') returned '${exit_code} '" >&2
101+ fi
102+
103+ echo " ${exit_code} "
91104}
92105
93106wait_for_vm_to_come_up
You can’t perform that action at this time.
0 commit comments