Skip to content

Commit 90cf676

Browse files
committed
CI: get_windows_updates_remaining falls back to guest.run
... instead of only using `guest.run`
1 parent b6e6467 commit 90cf676

File tree

1 file changed

+20
-7
lines changed
  • ci/tasks/install-windows-updates

1 file changed

+20
-7
lines changed

ci/tasks/install-windows-updates/run.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,26 @@ function wait_for_vm_to_come_up() {
8181
}
8282

8383
function 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

93106
wait_for_vm_to_come_up

0 commit comments

Comments
 (0)