How to execute Linux shell script from Windows Power Shell script.

Is there way to execute shell script on Linux Box from Windows Power shell script?
SURESH0518Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

timgreen7077Exchange EngineerCommented:
I'm going to go out on a limb here and say natively you can't execute PowerShell on a Linux box. power shell is a subsystem for Windows. You may be able to do this with some 3rd party software but not natively.
0
timgreen7077Exchange EngineerCommented:
here is a link to show you how to install PowerShell on Linux machines l

https://www.howtogeek.com/267858/how-to-install-microsoft-powershell-on-linux-or-os-x/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dr. KlahnPrincipal Software EngineerCommented:
Is there way to execute shell script on Linux Box from Windows Power shell script?

We need some more information, because as I read the question the situation either can't occur or is unlikely.

There's a linux-based computer.  It's running a Powershell script, which is possible but seems unlikely - it would require at least linux Powershell Core.  The script is a Windows Powershell script, which probably wouldn't run on linux properly if it was written for Windows Powershell.  And the desired result is to run a linux shell script from out of the Powershell script.

Can that be the situation?  Would you give us some more information on the setup and the desired result?

<opinion>
linux ain't windows.  In Rome it's best to do as the Romans do, i.e., on linux, use the native scripting.
</opinion>
0
Discover the Answer to Productive IT

Discover app within WatchGuard's Wi-Fi Cloud helps you optimize W-Fi user experience with the most complete set of visibility, troubleshooting, and network health features. Quickly pinpointing network problems will lead to more happy users and most importantly, productive IT.

arnoldCommented:
There are several examples
https://www.jonathanmedd.net/2013/08/using-ssh-to-access-linux-servers-in-powershell.html

Your Windows system needs a command line ssh application,
Setup the connection to the Linux system
Execute the command '/full/path/to/script' or run a sequence of commands.
0
arnoldCommented:
the question is a request on scripting a Windows host to connect to a Linux system and run a Linux, existing script.
Powershell on the Windows host is the preferred scripting tool the asker is interested in using.
I am not reading into the question that the user wants to run a powershell script within the Linux server environment, though Microsoft has links/references on installing powershell interpreter on the various platforms Linux as well as a Apple's, Mac OS X
0
huacatCommented:
1. install ssh client at your windows box
2. Create ssh key via command "ssh-keygen" at your windows box, it will generate two file: id_rsa, id_rsa.pub, open id_rsa.pub and copy all lines
3. login into your Linux box via ssh client, please remember save server key info when connect to you Linux server first time, and edit the ~/.ssh/authorized_keys(create if not exists), append or input the id_rsa.pub text into it.
4. now your can run Linux script at Linux box in power shell window like:
ssh linux_box_user_name@linux_box_server_ip "linux command"
0
nociSoftware EngineerCommented:
I 2nd the SSH option.
0
timgreen7077Exchange EngineerCommented:
Enough information was provided so user can install PS on a linux box and run PS commands remotely from a linux box.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.