I am having an issue with importing PowerShell modules into a runbook in an automation account. It's a simple script to look at Exchange groups and email a list of matching groups out. It falls down at almost the first step: import-module exchangeonlinemanagement.
I installed the module in the normal way - from the gallery. Although it did import the module, the next command - connect-exchangeonline failed with "System.Management.Automation.RuntimeException: Unable to find type [Microsoft.Exchange.Management.RestApiClient.ExchangeEnvironment]."
Searching online, it suggested downgrading to version 3.5. I did that using the Azure Automation tab on https://www.powershellgallery.com/packages/ExchangeOnlineManagement/3.5.0
Now, when it reaches the import command it says that there is no module with that name. "The specified module 'ExchangeOnlineManagement' was not loaded because no valid module file was found in any module directory." Searching online doesn't provide any useful suggestions.
The commands work fine in the CLI.
Does anyone have any suggestions?