Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run PowerShell scripts without installing PowerShell?

Tags:

powershell

Is there a way to bundle PowerShell such that I don't have to install it on the OS? Ideally I'd like to use it in my build process, but I want something that's self-contained; I don't want to rely on each client computer installing PowerShell. I'm thinking I'd build a console app that hosts a PowerShell environment, but bundles the PowerShell assemblies locally.

Assuming it's possible, are there any royalty/licensing issues with such a setup?

like image 266
Peter Seale Avatar asked Jan 27 '09 04:01

Peter Seale


People also ask

How do I Run a PowerShell script manually?

In File Explorer (or Windows Explorer), right-click the script file name and then select "Run with PowerShell". The "Run with PowerShell" feature starts a PowerShell session that has an execution policy of Bypass, runs the script, and closes the session.

Can I Run PowerShell command from CMD?

You need to write the keyword “powershell” with a “-file” parameter followed by the path of the script to run the PowerShell script from CMD.

How do I Run a PowerShell script from a PowerShell script?

To run a script, open a PowerShell window, type the script's name (with or without the . ps1 extension) followed by the script's parameters (if any), and press Enter.


2 Answers

I'm not sure how much time I'll have to be able to see if the libraries can be somewhat independently copied. You are expecting the .NET Framework 2.0 to be on the machine?

There is some information here: http://karlprosser.com/coder/2008/06/19/portable-powershell-part-2-roll-your-own-plus-a-challenge/

But this isn't officially supported by Microsoft. Microsoft's stance will likely be that you must install PowerShell with the msi/msu or add the feature.

like image 99
Marco Shaw Avatar answered Oct 13 '22 20:10

Marco Shaw


You can host a powershell runtime inside a .net application using the System.Management.Automation dll, but I believe to run this you still need to have access to the powershell runtime on the machine. Unless there is a way to contain the whole runtime inside the applicaiton, which form my research does not seem possible, you will need to install powershell on each machine. If its any consolation, at the minute windows 7 comes with powershell installed by default.

like image 32
Sam Cogan Avatar answered Oct 13 '22 19:10

Sam Cogan