maester icon indicating copy to clipboard operation
maester copied to clipboard

Azure Automation errors

Open oliphanj-bsd opened this issue 1 year ago • 4 comments

I followed the instructions for configuring Maester in Azure Automation and these are the 3 errors I got. 1. MethodInvocationException: Exception calling "ShouldContinue" with "2" argument(s): "A command that prompts the user failed because the host program or the command type does not support user interaction. The host was attempting to request confirmation with the following message: PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\ContainerUser\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now?"

Find-Module: C:\usr\src\PSModules\Maester\internal\ConvertTo-MtMaesterResults.ps1:44 Line | 44 | $latestVersion = (Find-Module -Name Maester).Version | ~~~~~~~~~~~~~~~~~~~~~~~~~ | NuGet provider is required to interact with NuGet-based repositories. Please ensure that '2.8.5.201' or newer version of NuGet provider is installed.

Invoke-MgGraphRequest: C:\usr\src\PSModules\Maester\public\Send-MtMail.ps1:150 Line | 150 | Invoke-MgGraphRequest -Method POST -Uri $sendMailUri -Body $mailR …

oliphanj-bsd avatar Jul 17 '24 18:07 oliphanj-bsd

I hit the same issue and found that it is related to what PowerShell runtime version is used for the runbook.

The issue is present when using PowerShell 7.2, but not in 5.1.

I think this could be resolved by using Find-PSResource instead of Find-Module to avoid having to install the Nuget provider on the sandbox workers in Azure Automation.

The PSResourceGet module would need to be added as a prerequisite for this to work (it will be included by default in PowerShell 7.4, but as of now Azure Automation supports 7.2).

janegilring avatar Jul 19 '24 12:07 janegilring

It should be fixed if you add the following packages to the Runtime Environment:

  • Nuget
  • PackageManagement

schuelepatrick avatar Sep 03 '24 08:09 schuelepatrick

Also managed to get everything to work after installing both NuGet and PackageManagement as modules in the Azure Automation Account. So this should at least be added to the documentation. Another thing I am wondering is how we add/save custom-tests to Azure Automation. Do we have to fetch these from somewhere every run?

One solution for this is using a HybridVM to run the Azure Automation with saved custom-tests. But it would be nice to have a good way of doing this out of the box

magnusjak avatar Sep 13 '24 10:09 magnusjak

Created a pull request to add this to the documentation https://github.com/maester365/maester/pull/479

BurgerhoutJ avatar Sep 25 '24 13:09 BurgerhoutJ