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?
 
timgreen7077Connect With a Mentor Exchange 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
 
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
 
Dr. KlahnConnect With a Mentor Principal 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
Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

 
arnoldConnect With a Mentor Commented:
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
 
huacatConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.