Hi, there is a workflow for patching HA deployments, as ideally you don't want a whole bunch of failovers. The process is described here if you haven't seen it. https://enterprise.arcgis.com/en/portal/latest/administer/windows/apply-patches-and-updates-to-highl...
If you still wanted to do it automatically then I would wrap it all up in a powershell script and use remoting to do the patching. That way you could patch secondary first, stop the service, patch primary and restart the secondary service for portal and datastore assuming you are ok for downtime during the patching window and just schedule the PS1 script. Just be aware you have to tweak the execution policy when scheduling PS1 scripts via scheduled tasks. With server it doesn't matter, you can just stagger the scheduled tasks (separate days) to run the patch utility as there isn't any failover. I've also seen the ha_failover file get tweaked for patching so portal doesn't failover over while the primary patches.