RobertCrane Thanks for your comments!
Regarding the Note: Yes that' correct, you need to add the line of code
Install-Module Microsoft.Graph -AllowPrerelease -AllowClobber -Force
at the beginning of your PowerShell script to ensure that all further commands using the module will run without an error. This is because the code is executing on an agent that we don't know what has installed, so not our local machine.
Regarding the “CompliancePolicy_Export_Import.ps1” you are right, we don't have this in samples mainly because every organization and developer/IT Pro would have a preferred way how to write it. Some will prefer to have two separate scripts Export from DEV, then intermediate step to save JSON files in a folder, then Import to PROD. Or, export from DEV and import to PROD each of JSONs in one go (combine two scripts in one script).
You can follow the guide, and use a sample: CompliancePolicy_Add.ps1 first, and then decide how you want to combine Add and Export scripts together as a next step.
The PowerShell example, CompliancePolicy_Add.ps1, is simply a script that creates a compliance policy with some static values. You’re welcome to modify that script to accommodate any type of compliance policy you wish to generate. The same repository has an export compliance policy script which exports a JSON file containing the policy information.
Hope this helps!