1

Our company has some computers with an older version of Powershell as not all machines are allowed to receive certain updates due to dependencies. I am using the nuget-extension Microsoft.PowerShell.5.1.ReferenceAssemblies on computers with Powershell 5.1 and Microsoft.PowerShell.5.0.ReferenceAssemblies on computers with Powershell 5.0 in my C# CmdLet Project however I can not use both together.

How can I support multiple Powershell versions in my C# CmdLet project?

Itchydon
  • 2,572
  • 6
  • 19
  • 33

1 Answers1

0

Use the PowerShellStandard.Library package to create modules (cmdlets) that run across multiple versions and even editions; i.e., they run on both Windows PowerShell and PowerShell [Core].

  • Use version 3 to create cmdlets that run on PowerShell version 3 and later.

    • Curiously, the latest 3.x package published is 3.0.0-preview-02, from 2018 - I don't know why.
  • Use version 5.1 to create cmdlets that run on PowerShell version 5.1 and later.

See the PowerShell Standard GitHub repo for more information.

Note:

  • Said PowerShellStandard.Library package is meant for developing code that runs from inside PowerShell on a given machine; that is, it needs an existing PowerShell installation.

  • By contrast, the following packages allow you to bundle PowerShell with your application:

mklement0
  • 382,024
  • 64
  • 607
  • 775