the script is stopping before the reboot.
Are you sure it's stopping? This looks like a potential infinite loop.
Start-Sleep -Seconds 30
Does SCCM have a log somewhere that records the value of EvaluationState as updates are installed? You could also add a counter in there so that if you've been sleeping longer than say 20 minutes, to break out of that loop and go ahead and check the reboot status.
I implemented patching on our Windows servers, but we used WSUS and the COM interface to Windows Update. What I found was that the "second set of patches" didn't show up until the pending ones were installed and AFTER the reboot had occurred. To account for that, our script created a scheduled task to run at startup time to perform what I termed "phase 2". The script would again do any patch installs, delete the phase 2 scheduled task and then reboot a second time if necessary.
I don't know how SCCM works but you may have to use the scheduled task technique to get everything installed. All of our scripts ran as the SYSTEM account (via the task scheduler) and there was no interactive user interface. If you schedule a script to run ONSTART, you can't display a message box. You don't have a user. Might need a second script.