r/PowerShell•
SMFX

Blog Post: Sharing via Class through Nested Modules

Script Sharing

Fiddling around on a recent module, I stumbled on an odd trick with Classes and nested modules that allowed sharing of values without Functions, large scoped variables, or reference objects. I typed it up here:

https://smallfoxx.github.io/Classes,-Nested-Modules,-and-Sharing-Values/

TL;DR: putting a variable and Class w/ ScriptProperties in a psm1 and utilize PS5+ using, you can access the same variable via any instance of the Class.

Posted Jan 16, 2020, 8:58 PM UTC

100

No comments yet

Nobody commented on this post, or the comments weren't captured.