Enabling scheduling on Publishing Pages in SharePoint Online (Office 365) using CSOM and PowerShell
Scheduling is easily enabled through the web interface when configuring the "Pages" library, but when deploying solutions using PowerShell, this must be automated as part of the configuration. Unfortunately, as many other sources also state, this is not directly supported in the Client Side API (CSOM).
The solution is to manually set up the Pages library the same way Microsoft does by adding two event receivers, changing some columns from hidden to visible and adding them to the default view.
Note: This example uses commands from the Office Dev PnP PowerShell library, ex. "Get-SPOContext". I recommend using this library for working this PowerShell and SharePoint (both Online and On-Premises).
Function to enable Scheduling on a library on a given web site:
On line 11 an additional function is needed to create the parameters for the "Load" method:
How to enable scheduling: