-
Notifications
You must be signed in to change notification settings - Fork 32
SafeGetValue() method not available in PSv4 #34
Comments
As a side note, it was difficult to find out where the SafeGetValue method was coming from, it could have been an extended attribute added by Powershell to the .Net classes. But that doesn't appear to be the case. My desktop (Running PSv5) and one of the server (Running PSv4) are loading the same DLL: But digging deeper into the GAC to confirm that the DLL is the same, I found my answer: Not sure if these DLL's are installed into the GAC by Powershell or .NET Framework install. But there is a difference in the version. |
Thanks for reporting this @bwright86. I'll take a look. |
I know this is going to sound a bit crazy, but @bwright86 is there any reason you wouldn't move to PSv5.1 on your servers? There are probably legit reasons, but the benefits are enormous from both a powershell perspective but also a security perspective (better logging, etc.) I'll see if I can help out with this one but I feel like upgrading is a really, really good idea if you can. |
Lol, @miketheitguy, it does not sound crazy. We are in the process of upgrading our servers to PSv5.1, but it takes a while for my server team to push it out in all environments. I can’t wait to realize the benefits of the new version, as I have a few projects on hold that are waiting for this (e.g. PSModule repo, hardening steps, and logging to enable.) I currently cloned this repo and changed it to support PSv4, so I have been able to run my first infrastructure tests 🙂 But I wanted to raise awareness around that method not being available in older versions of PowerShell or .Net Framework. Thanks for the response! |
The
Get-TestFromScript
function uses the method callSafeGetValue()
against[AST]
types. This method does not appear to be available in PSv4 consoles. I also don't see the need to call this method for the logic being performed.Current Behavior
Method invocation failed because [System.Management.Automation.Language.ArrayLiteralAst] does not contain a method named 'SafeGetValue'.
Possible Solution
Extract tags with
$tagElements.Elements.Value
, instead of$tagElements.SafeGetValue()
Operation-Validation-Framework/OperationValidation/Private/Get-TestFromScript.ps1
Line 43 in 0bc93ef
Operation-Validation-Framework/OperationValidation/Private/Get-TestFromScript.ps1
Line 48 in 0bc93ef
Steps to Reproduce (for bugs)
-Tag
parameterGet-OperationValidation
Output:
Context
Attempting to write and use OVF modules in my server environment, and do not currently have PSv5.1 installed.
Your Environment
The text was updated successfully, but these errors were encountered: