I have a DLL assembly that returns a list (EmailItem). EmailItem is a custom class that includes some properties that are lazy to load due to the processing time that they execute to execute. They are mostly helpers based on my business requirements.
When I work with these objects in my Windows and console applications, these properties are quietly waiting for a call there.
However, if I use PoSh to retrieve a set of these classes, then use the Where-Object to filter them, each of these properties is evaluated, even if they are not specified in the Where-Object script block or elsewhere in the script. I tried to write a custom filter, but experienced the same behavior. Even projecting values that worry me about using Select-Object does the same thing.
My best guess is that objects are converted to PSObjects, and PowerShell populates the properties.
Any ideas how to avoid this or disable it for this script? I am in the process of adding “lightweight” objects that these helpers do not include, but this annoys the amount of work just to support my favorite Windows scripting language.
Thanks for any tips!
source share