I currently use the following structure in my scripts:
HighLevel.ps1 LowLevelModule1.psm1 LowLevelModule2.psm1 ...
Now I set strict mode in the ps1 file to get at least some type safety at runtime. Unfortunately, cllaing Set-StrictMode -Version Latest will enable strict mode only for the current area and all child areas (this is by design. Proof: https://technet.microsoft.com/en-us/library/hh849692.aspx ).
As far as I understand the current PS architecture, changing strict mode in the ps1 file changes the script-level configuration. But modules have their own script scope, so modules do not inherit parent rules.
As a workaround, I can put Set-StrictMode in every PSM1 file, but this is not very suitable, because I could not allow the client of my module to decide whether to enable strict mode or not.
The same problem exists for the configuration of $VerbosePreferences . This configuration is also included for each scope, so I have to spread this information across the borders of the modules on how to do this.
Any suggestions on how to change strict mode and detailed preferences globally?
PS Changing the $ profile for these purposes is not an option.
source share