1

Is there a good way to check if the PS version is, for example >= 5.0.0?

NOTE: I'm already using this NugetPackage: Microsoft.PowerShell.5.ReferenceAssemblies

8
  • 3
    @lwolf It's not a duplicate. I'm trying to do it from .NET (C#) Commented Apr 10, 2019 at 18:37
  • 1
    If you're using a specific PowerShell assembly, then that's the version you're using in your application. What's on the system doesn't really matter. But the linked question will still tell you a version, if you execute that PowerShell from within C#. If you want to know the version of one of the possible executables, then you should start that executable process and check its version. Remember that Windows PowerShell and any number of PowerShell Core versions can exist side-by-side. So you have to decide what it is you want to do and know before this question can reliably be answered. Commented Apr 10, 2019 at 18:41
  • 2
    @briantist You are not correct. Reference assemblies are only for reference, them does not need to contain actual code. Application will use assemblies provided by system. Commented Apr 10, 2019 at 18:53
  • 2
    Thank you @PetSerAl, you are correct, my mistake. I think this can be still be answered by the linked question, but if you think it deserves its own feel free to reopen (or comment as such and I'll do it). Commented Apr 10, 2019 at 18:55
  • @briantist - i think this should be re-opened. OP is specifically asking a way to do this from C#, and the linked question is PowerShell. please re-open. Commented Mar 19, 2021 at 16:34

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.