Azure / Azure/azure-powershell
Many sub modules with .Autorest: Remove the use of write-information for module load message
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
### Description
Seems like all modules have a *.Autorest\*.psm1 file (where * is sub module name) that contains the following code:
`Write-Information "Loaded Module '$($accountsModule.Name)'"`
For us that use the information stream for logging we get unwanted pollution of the info stream from these messages, and makes us have to use -InformationVariable infoVar on almost everything to be able to scrub the stream output:
```
Write-Information -MessageData "$($infoVar| Out-String -Stream | Select-String -Pattern "Loaded Module" -NotMatch)"
```
We use alot of ForEeach-Object -Parallel with calls to Az inside, and as this loads Az modules for each, there is a lot of pollution of the information stream from the use of Write-Information for the module load message in Az.
Please instead use, as this is often by default silenced with $VerbosePreference = "SilentlyContinue":
`Write-Verbose -Message "Loaded Module '$($accountsModule.Name)'"`
This is especially anoying in Azure DevOps, where the AzurePowershell task uses $InformationPreference = "Continue"
The most problematic is Az.Resources as we use this all over the place.
### Issue script & Debug output
```PowerShell
No output
```
### Environment data
```PowerShell
PS C:\eunomia> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Microsoft Windows 10.0.22635
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
### Module versions
```PowerShell
PS C:\eunomia> Get-Module Az* | Format-Table -AutoSize
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.17.0 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-A…
Script 7.4.1 Az.Network {Add-AzApplicationGatewayAuthenticationCertificate, Add-AzAp…
Script 6.16.1 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAs…
```
### Error output
```PowerShell
No error output, but information stream when importing Az.Resources:
Loaded Module 'Az.Accounts'
Loaded Module 'Az.Authorization'
Loaded Module 'Az.Accounts'
Loaded Module 'Az.MSGraph'
```
Contributor guide
Research direction
Start with the *.Autorest*.psm1 module files described in the issue, especially the Az.Resources-related modules, and locate each `Write-Information "Loaded Module..."` call. Check module imports with the information stream enabled, then confirm that loading the affected modules no longer emits these messages while the intended verbose load message remains available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100