I’m sharing the following code snippet as I’ve used it a few different ways at VCSPs to update the SSL certificate for cloud gateways. The code itself wouldn’t publish embedded in the post, but you can access it by clicking here.
In my lab at home, I use this and some SMTP scripts with Certify the Web to automatically renew and replace Let’s Encrypt certificates.
At VCSPs, I’ve paired it with an RMM, file share, PFX file, and the Import-PfxCertificate cmdlet to mass replace certificates before they expire.