Azure / enterprise-azure-policy-as-code

Enterprise-ready Azure Policy-as-Code (PaC) solution (includes Az DevOps pipeline)
https://azure.github.io/enterprise-azure-policy-as-code/
MIT License
415 stars 219 forks source link

EnterprisePolicyAsCode module - Don't show verbose output unless enabled #583

Closed o-l-a-v closed 4 months ago

o-l-a-v commented 4 months ago

Is your feature request related to a problem? Please describe.

Starting a fresh PowerShell session, then doing Import-Module -Name 'EnterprisePolicyAsCode shows verbose messages.

PS C:\Users\olavb> Import-Module -Name 'EnterprisePolicyAsCode'
VERBOSE: Exporting function 'Build-DeploymentPlans'.
VERBOSE: Exporting function 'Build-PolicyDocumentation'.
VERBOSE: Exporting function 'Convert-MarkdownGitHubAlerts'.
VERBOSE: Exporting function 'Create-AzRemediationTasks'.
VERBOSE: Exporting function 'Create-AzureDevOpsBug'.
VERBOSE: Exporting function 'Create-GitHubIssue'.
VERBOSE: Exporting function 'Deploy-PolicyPlan'.
VERBOSE: Exporting function 'Deploy-RolesPlan'.
VERBOSE: Exporting function 'Export-AzPolicyResources'.
VERBOSE: Exporting function 'Export-NonComplianceReports'.
VERBOSE: Exporting function 'Get-AzExemptions'.
VERBOSE: Exporting function 'Get-AzPolicyAliasOutputCSV'.
VERBOSE: Exporting function 'New-AzPolicyReaderRole'.
VERBOSE: Exporting function 'New-EPACDefinitionFolder'.
VERBOSE: Exporting function 'New-EPACGlobalSettings'.
VERBOSE: Exporting function 'New-EPACPolicyAssignmentDefinition'.
VERBOSE: Exporting function 'New-EPACPolicyDefinition'.
VERBOSE: Exporting function 'New-PipelinesFromStarterKit'.
VERBOSE: Exporting function 'Remove-AzPolicyExemptionEpac'.
VERBOSE: Exporting function 'Set-AzPolicyExemptionEpac'.
VERBOSE: Exporting function 'Sync-ALZPolicies'.
WARNING: The names of some imported commands from the module 'EnterprisePolicyAsCode' 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.
PS C:\Users\olavb>

It's not common to show verbose output unless it's explicitly enabled by the user. No other module I can think of does this, I see no reason for EPAC PS module to do it either.

Describe the solution you'd like

Ideally it should look like this:

PS C:\Users\olavb> Import-Module -Name 'EnterprisePolicyAsCode'
PS C:\Users\olavb>

Describe alternatives you've considered

Redirect verbose output stream to $null.

PS C:\Users\olavb> Import-Module -Name 'EnterprisePolicyAsCode' 4>$null
WARNING: The names of some imported commands from the module 'EnterprisePolicyAsCode' 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.
PS C:\Users\olavb>

Additional context

anwather commented 4 months ago

Fix in development environment - as it is non breaking issue I'll close this and it will be included in the next version