Description
Today the auto-generated code that the Microsoft.Graph bundle of modules is comprised of uses Write-Information
very liberally to output additional information to the caller. This is a bad design decision because Write-Information
is handled differently than other information streams ([related: PowerShell/PowerShell/issues/13631). When you invoke PowerShell programmatically using the SDK, information records will always be output to the information stream in PowerShell 7.0.3 and earlier as well as in Windows PowerShell 5.1 and earlier. The end result is information stream content showing up by default in scripts run through a platform or service that runs PowerShell scripts, unless the platform is smart enough to work around the issue with information stream handling at the SDK level (but that workaround should not be necessary!).
Even putting that SDK issue aside, the Information stream is a bad choice for what you are trying to do.
The Verbose
stream is used to deliver information about command processing that is meant to be helpful to a scripter that is debugging/troubleshooting a command that they are using.
The Debug
stream is used to deliver information about command processing that is meant to be helpful to the command author that is debugging/troubleshooting a command that they have written.
The Information
stream is a newer stream, intended to support the transmit of structured data between a script and its callers (or hosting environment).
You are clearly using the Information
stream as if it was the Verbose
stream today.
Further, the last message you output from each of your modules does not add any value. For example, you have the following in your Microsoft.Graph.Users.User.psm1 file at the end:
Write-Information "Loaded Module '$($instance.Name)'"
This message does not provide me as a user any additional information that will help me debug or troubleshoot a command. It appears at the end, after the import of the module has finished, at which point I already know if the command was successful or not based on the presence of warnings or errors.
My request to you to clean this up is threefold:
- Replace all use of
Write-Information
withWrite-Verbose
in your auto-generated PowerShell code. - Remove the
"Loaded Module '$($instance.Name)'"
message from the bottom of your psm1 files as it is not helpful or necessary. - Reconsider other places where you use
Write-Verbose
, and only keep those messages if they will actually help a scripter diagnose or troubleshoot an issue when a Graph module is not loading as expected.