Force renewal of Content Types in SharePoint Online

In 2014 I wrote a post on how to force the renewal of the content types in an on-premises environment and got a request on that post if it was possible to do the same in Office 365.

After a short research and some changes to the original script, see below for the result.
It uses the Office Dev PnP PowerShell CmdLets.

See below for the version for SharePoint Online