-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot load module in PS4 due to "class" keyword #92
Comments
What happens when you run |
I think I will just check for |
Ugh, that is annoying. Even though I am not calling to create the class (the If statement should have taken care of that) the parser still sees the keyword and throws an error. It looks like a classes file will be the way to go...or use a here string and call Invoke-Expression. |
This should be fixed in the latest update. |
The PSEdition property doesn't exist at all on my system, as you suspected. Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.
PS C:\Users\replica> $PSVersionTable.PSEdition
PS C:\Users\replica> Interesting to hear that it's a parser problem...I was actually just thinking of "borrowing" your approach on this module for custom classes / objects. Sending that to Invoke-Expression is a really cool workaround. Anyway, the latest version works great. Thanks for the fix! |
Hello!
After updating to version 1.7.2.3 of this module, I'm no longer able to import the module in a PowerShell 4 session. Here's the error:
The test system is Server 2008 R2. The module still works as expected on a Win7 box with PS 5.0 installed.
I'm not super familiar with classes yet, but would it be possible to move the class definitions into a separate .ps1 file? Then the module file itself could check the PSVersionTable and load either the "class" .ps1 file or the "Add-Type" .ps1 file as appropriate.
Thanks again for the amazing work on this. It's been a huge help!
The text was updated successfully, but these errors were encountered: