Reset Configuration Remotely

Is there a way to upgrade router os to the latest version, and then reset the configuration, and then add my script to configure the router so I can vpn back in, and, do this all remotely?

It is. But many things may went bad that will lead to loosing the connection to such device.

Make update and restart. Prepare the script and point at the script when removing configuration.