5

My Application is dependent on PowerShell version 5. But some old windows system have not installed the same version where our application is running. So is there any way to run standalone PowerShell which I put in my application folder. So my application is not dependent on system PowerShell.

2
  • Long story short - no. You can't have "portable" powershell. Sep 13, 2018 at 11:50
  • 3
    Did you try to use PowerShell Core? It is indeed "portable" but it's not Windows PowerShell version 5.
    – Clijsters
    Sep 13, 2018 at 11:57

2 Answers 2

7

Disclaimer: We don't know your application and we don't know, why exactly it depends on PowerShell. Further we don't know if it depends on Windows PowerShell or on PowerShell in general. We also don't know if it requires specifically version 5 or would run in newer versions too.


To answer the core of your question:

So is there any way to run standalone PowerShell which I put in my application folder.

Yes, there is!

Microsoft introduced PowerShell Core, which started as a fork and is a cross-platform edition that runs on Windows, macOS, and major Linux distros. You can download PowerShell binary archives from GitHub, extract them and just run pwsh.exe.

Please beware:

While it provides a huge amount of well-known PowerShell-cmdlets and some (most) of the Windows PowerShell behaviour, it is important to know the difference between PowerShell Core and Windows PowerShell. Refer to the repository's README for further resources.

3
  • 3
    Note that they may not use PowerShell the shell, but rather PowerShell the automation technology hosted in the application, in which case pwsh.exe is rather irrelevant.
    – Joey
    Sep 13, 2018 at 12:51
  • Thx for the note. I just "assumed", the application consists of some ps1 files. OP didn't say much about it.
    – Clijsters
    Sep 13, 2018 at 13:05
  • 1
    Thanks, @Clijsters it's Working. But Get-Counter command is not working. So any solutions to run this command in Powershell core.
    – Subhash
    Sep 14, 2018 at 7:04
0

No. You cannot have a portable version of Windows PowerShell for your application.

You also may not be able to install a newer version on an older operating system; e.g., you can't install PowerShell version 5 on Windows XP.

Windows Powershell versions depend on many things, such as OS Version, Microsoft .NET Framework, Windows Management Framework, WS-Management, Windows Management Instrumentation, Common Language Runtime, Graphical User Interface Requirements.

Here is a link with information about Windows PowerShell versions and their requirements.

I'd say it is best if you create your application so that it is compatible with the oldest possible version of PowerShell it will run with. It could be hard and tricky, but it's the only to way to ensure proper backward compatibility.

1
  • Your answer is not incorrect, but it seems your anwer doesn't take PowerShell Core into account.
    – Clijsters
    Sep 13, 2018 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.