You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
-Verbose not passed to other module's functions (as opposed to $VerbosePreference) #25739
# Two modules:# - one with functions Foo and Bar# - one with function Another# Foo call's Bar from the same module and Another from a different module$null=New-Module {
functionFoo {
[CmdletBinding()] param()
# own outputWrite-Verbose"Foo's verbose output."# call Bar from same module
Bar
# call Another from other module
Another
}
functionBar {
[CmdletBinding()] param()
Write-Verbose"Bar's verbose output."
}
}
$null=New-Module {
functionAnother {
[CmdletBinding()] param()
Write-Verbose"Another's verbose output."
}
}
# -Verbose doesn't seem to be passed through to secondary modulesWrite-Host"1st attempt (-Verbose):"
Foo -Verbose
# VerbosePreference on the other hand does seem to be passed through to secondary modulesWrite-Host"2nd attempt (VerbosePreference):"$VerbosePreferenceOriginal=$VerbosePreference$VerbosePreference='Continue'
Foo
$VerbosePreference=$VerbosePreferenceOriginal
>$PSVersionTable
Name Value
---------
PSVersion 7.5.2
PSEdition Core
GitCommitId 7.5.2
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
#12516 is indeed similar, but it was not resolved, there were no answers and it is closed, so I opened this one. Feel free to close one or the other as long as one stays open or is resolved or documented or whatever.
The common -Verbose (switch) parameter is by - problematic - design translated into a function-local $VerbosePreference variable with value 'Continue'.
Such a preference variable is not honored across module boundaries : functions in a given module do not see an outside caller's preference variables (though it's possibly to go out of one's way to access them).
Activity
similar-issues-ai commentedon Jul 8, 2025
We've found some similar issues:
If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.
boernsen-development commentedon Jul 8, 2025
#12516 is indeed similar, but it was not resolved, there were no answers and it is closed, so I opened this one. Feel free to close one or the other as long as one stays open or is resolved or documented or whatever.
mklement0 commentedon Jul 8, 2025
The real duplicate (also linked to from #12516) is:
In short:
The common
-Verbose(switch) parameter is by - problematic - design translated into a function-local$VerbosePreferencevariable with value'Continue'.Such a preference variable is not honored across module boundaries : functions in a given module do not see an outside caller's preference variables (though it's possibly to go out of one's way to access them).
microsoft-github-policy-service commentedon Jul 9, 2025
📣 Hey @boernsen (@boernsen-development), how did we do? We would love to hear your feedback with the link below! 🗣️
🔗 https://aka.ms/PSRepoFeedback