Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automation - Invoke-ARI command was found, but the module could not be loaded #238

Open
farreciado opened this issue Nov 28, 2024 · 8 comments

Comments

@farreciado
Copy link

Hello
I tried to run ARI in a run book on Azure Automation where I have other runbooks working. Followed the steps to configure a runtime, added needed modules etc.

Runbook it's just one line
Invoke-ARI -TenantID "TENANT_ID" -Automation -SkipDiagram -SkipAPIs -StorageAccount "STORAGE_NAME" -StorageContainer "reports" -Debug

When I test the code in test pane, I got this message:

The 'Invoke-ARI' command was found in the module 'AzureResourceInventory', but the module could not be loaded. For more information, run 'Import-Module AzureResourceInventory'.

After checking other issues here, I tried downgrading the Az module version to 8.0, but didn't help.

Packages installed
Image

@Claudio-Merola
Copy link
Collaborator

Hello @farreciado

The automation test pane streamed any error or issue besides the one you mentioned?

The account seems to be correctly configured and the runbook line is correct.

Did you configured the runtime with powershell version 5.1?

Can you test to change the runbook line to: "Import-Module AzureResourceInventory"?

Just to see what is the error message.

@farreciado
Copy link
Author

Hi @Claudio-Merola , I left that single line, now the output is
The required module 'PackageManagement' is not loaded. Load the module or remove the module from 'RequiredModules' in the file 'C:\usr\src\PSModules\PowershellGet\PowershellGet.psd1'.

Let me know further tests, thanks.

@Claudio-Merola
Copy link
Collaborator

That is odd,

are you using Runtime Environments, Hybrid Workers or the regular AA Runtime?

@farreciado
Copy link
Author

farreciado commented Nov 29, 2024

Regular runtime, an Azure Automation resource with 3-4 runbooks, used for little things, no configuration beyond what's minimum required

May be worth trying in a separate one?

@Claudio-Merola
Copy link
Collaborator

Claudio-Merola commented Nov 29, 2024

I would suggest to remove the "PowershellGet" module first and see how it goes as apparently that is the module that is giving issues (and it is not really necessary for the script to run)

@farreciado
Copy link
Author

I did, but no difference.

I created a new runtime without adding the PowershellGet module. Fails again, showing this warning
Both Az and AzureRM modules were detected on this machine. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide
Exception calling "Initialize" with "1" argument(s): "Object reference not set to an instance of an object."
The names of some imported commands from the module 'AzureResourceInventory' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.

I tried to uninstall AzureRM to avoid such conflict, with no success.

@Claudio-Merola
Copy link
Collaborator

That error should not prevent the Runbook to complete the execution and create the Excel file.

Anyways I updated some components in the module and not with the version 3.5.12 it should work in the automation (even with Runtime 7.4)

Can you test it?

@renanhermann
Copy link

Hello @Claudio-Merola I still have problem, even that you release version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants