davidobrien1985 / DscResources

This repository will contain custom PowerShell DSC Resources
MIT License
22 stars 9 forks source link

Resource should allow ArgumentList parameter for modules that require addtl flags #18

Open ArtisanByteCrafter opened 5 years ago

ArtisanByteCrafter commented 5 years ago

Example: Some modules require additional parameters for successful unattended installation. Install-Module UniversalDashboard -AcceptLicense

When run from DSC, the following error is produced:

License Acceptance is required for module 'UniversalDashboard'. Please specify '-AcceptLicense' to perform this operation.
    + CategoryInfo          : InvalidArgument: (Microsoft.Power....InstallPackage:) [], CimException
    + FullyQualifiedErrorId : ForceAcceptLicense,Install-PackageUtility,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
    + PSComputerName        : computername

Something like this would be nice:

PSModuleResource UniversalDashboard {
    Ensure          = 'Present'
    Module_Name     = 'UniversalDashboard'
    RequiredVersion = '2.3.2'
    ArgumentList    = "-AcceptLicense"
}
mwhisler commented 1 year ago

Agreed. Here's another example of trying to apply Az.ApplicationMonitor to a virtual machine for autoinstrumentation. I need to do this with DSC, but need to pass an additional flag for accepting the license. https://learn.microsoft.com/en-us/azure/azure-monitor/app/application-insights-asp-net-agent?tabs=getting-started

Otherwise, you'll see these errors in the DSC logs: {"time": "2023-05-12T10:03:54.990-5:00", "type": "error", "message": "License Acceptance is required for module 'Az.ApplicationMonitor'. Please specify '-AcceptLicense' to perform this operation."},