Wednesday, February 8, 2017

The change that makes PowerShell classes' methods run in full-language mode

Yesterday, I noted that PowerShell-defined classes' method bodies are restricted by the runspaces in which they execute. That causes problems for some use cases, and I wanted to figure out how to fix it. Eventually, I found the place to change: InvokeHelper and InvokeHelperT in ClassOps.cs. Just add this line right before the InvokeAsMemberFunction and InvokeAsMemberFunctionT calls:

sb.LanguageMode = PSLanguageMode.FullLanguage;

No comments:

Post a Comment