question

RajRaj-5385 avatar image
1 Vote"
RajRaj-5385 asked RobertTheBruce-2746 commented

import module failing in azure automation

Import module failed "Modulename" Error importing the module "name of the module". Import failed with the following error: Orchestrator.Shared.AsyncModuleImport.ModuleImportException: An error occurred during module validation. When importing the module to an internal PowerShell session, it was not able to be loaded by PowerShell. There is likely an issue with the contents of the module that results in PowerShell's not being able to load it. Please verify that the module imports successfully in a local PowerShell session, correct any issues, and then try importing again. It works on local powershell

azure-automation
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@RajRaj-5385 - Welcome to Microsoft Q&A platform and thanks for using this forum.

To provide a better assistance, could you please share script with the commandlets or modules you are using locally and trying the same in Azure Automation (please mask any sensitive information in the script) . Which would help us to troubleshoot the issue further.

Looking forward to your response. Thank you.

0 Votes 0 ·

@RajRaj-5385 - Can you please share additional information to further review your issue ? thank you

0 Votes 0 ·

hi @bharathn-msft I have a similar issue with Azure Automation. All I am doing is following the documentation here (https://docs.microsoft.com/en-us/azure/automation/learn/automation-tutorial-runbook-textual-powershell). The Hello World! worked fine but the complex part didn't. Below is my code and error
Code:

Import-Module Az.Accounts
Disable-AzContextAutosave –Scope Process

Output:

Import-Module : The specified module 'Az.Accounts' was not loaded because no valid module file was found in any module
directory.
At line:1 char:1
+ Import-Module Az.Accounts

Disable-AzContextAutosave : The term 'Disable-AzContextAutosave' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:3 char:1
+ Disable-AzContextAutosave –Scope Process

0 Votes 0 ·
Show more comments

0 Answers