Executing Powershell Scripts from Linux Servers

I have to run some powershell scripts from Linux hosts. What is the best recommended way to achieve this? I noticed on a powershell video, Jeffrey Snover from Microsoft executing powershell scripts from linux which kind of blowed me and now I need to know how to do this? Some people says hosting some web page in IIS and then execute, but I wonder if there is a recommended way?

Maruf Yunus

P.S. I am almost new to powershell, my bash and python script skills are way better. But I really liked the powershell features and impressed and the primary reason I am very interested in powershell to manage vmware infrastructure via powercli.

I did look at installing ssh server on windows, but most of the good ones requires buying a commercial ssh server for windows. But like to know if there is any other solution other than hosting something in iis or ssh server for windows.

You could set up a Windows 2012 server and use PowerShell Web Access

I presented on this at the Powershell Summit this year

If you look carefully you will see me using a Linux client machine to run PowerShell in a browser through the Windows 2012 PowerShell Web Access site
also see

(You may not have seen Snover actually executing PowerShell scripts from Linux - he modifies his PowerShell prompt to make it look like a Bash prompt, but it’s still PowerShell and it’s still running on Windows.)

PowerShell itself doesn’t natively use SSH. It uses something called Remoting, which uses the WS-Management protocol. If you have a Linux WS-Management client, then you can use it a lot like SSH to connect to a remote PowerShell instance running on Windows, and ask that copy of PowerShell to run commands. I’m not aware of any Linux WS-Management clients, but the protocol specification is published and it’s something that, in theory, someone could write.

In the meantime, PowerShell Web Access (PWA) is probably the way to go. As Richard notes, it’s available on Win2012 and later and does require IIS. You only need it on one “gateway” computer: You connect (via Web browser) to the PWA server, and it connects to whatever PowerShell-enabled machine you want to manage. It acts as a middleman to create an HTML PowerShell interface between you and the machine you’re managing.

Thanks all. Makes sense. Appreciate the quick response.

Just a quick note. PowerShell Web Access is cool in theory and practical in a pinch.

That being said, I would not recommend using it as a shell even to my enemies. It is quite limited and clunky. If you want to use PowerShell, use a Windows system.

You mentioned running scripts. PSWA means you connect and run things manually . A Scheduled Task, or some other means of running your PowerShell script would be a better bet if you don’t plan to run it manually.

Yes, could be nice if Microsoft shipped windows with SSH server (similar to what it has done with NFS support) and that could make things a lot more easier. Unfortunately I have to manage a mixed environment where i Have linux, freebsd and Windows. So SSH server could help. Yeah after looking a lot it does look like it requires some monkeying to call powershell scripts from linux servers.

Such a good tool but less interoperable with other systems. SSH built in support in windows could be so nice and could actually make windows more popular on the server side.

Again, no complain with powershell as I do think powershell was developed very good and actually better than bash where I do manipulate a lot of strings etc to get things working.

My last option is to buy a 3rd party ssh server.

Look at what’s available from /n software - they do a SSH server if I remember correctly

After some head scratching and research, I ended up overcoming this challenge through free open source product saltstack which I use for my other production multiple server management and orchestration purposes. With saltstack, you can configure a Windows system as a salt-minion (like a client or managed server) and then executing remote commands and perform various operations from Linux server. I also made a youtube video demonstrating executing a powershell script on a Windows 2012 R2 preview from a centos VM. Once I figured out it took me 15 minutes to try it our and prove out the theory.

Checkout this video and let me know if you have any thoughts: