Yeah, the problem is with propagating from a caller's scope to descendant scopes, with global one being an exception. Doesn't even have to be a different module. It's enough to call it from a wrapper script.
When you call it casually from VS Code, it gets dot-sourced, so your script scope functions as a global one. However, if you have a wrapper around the module function call, the global scope is now different.
So, coming back to your example, @astral knot , let's call it Test-Module.ps1 and comment out all the function calls, except for the last one, Get-foo # also fine.. prints verbose.
Now create another script in the same folder (let's call it Test-ModuleWrapper.ps1) and put in just one line: .\Test-Module.ps1. These two ways of calling our new script behave differently:
Preference Variables (works as expected)
$VerbosePreference = 'Continue'
$ErrorActionPreference = 'Ignore'
./Test-ModuleWrapper.ps1
Common Parameters (doesn't work as expected)
$VerbosePreference = 'SilentlyContinue'
$ErrorActionPreference = 'Continue'
./Test-ModuleWrapper.ps1 -ErrorAction Ignore -Verbose
Most common use case is when you want to create a mini-environment or a temporary script to call the functions you're testing from within it and, not wanting to mess with global preference vars, you add common parameters now and then.
I think everyone working with PowerShell encounters this issue sooner or later, and it might take quite some time figuring out what is wrong and why. And it's not even immediately obvious what exactly you need to google in this case, especially for beginners.
So for now using the Set-Variable cmdlet is the only viable workaround I know.