Managing Windows Powershell from Linux terminal
Some options:
- Install an SSH server on a Windows machine, SSH in, run Powershell on the Windows box
- Run an RDP client on Linux, RDP in, run Powershell on the Windows box
- Use Powershell Web Access, hit the POSH WA gateway server with a browser, run Powershell via the browser
http://technet.microsoft.com/en-us/library/hh831611.aspx
I'm not aware of any POSH executables for Linux, so you can't run POSH commands directly from a shell in Linux - you must first get into the Windows machine somehow, like RDP, remote console (DRAC, iLO), SSH, or POSH Web Access.
/Edit- looks like there are some options. http://sharpcodenotes.blogspot.com/2014/01/running-powershell-commands-from-linux.html
You could try and get OpenWSMan to do what you want, but i think you'd have to craft every command like a URL request rather than simply issue the correct Powershell command - as I said, there's no actual Powershell for Linux. You could install the WinRB ruby gem on every Windows machine and then run Ruby code on your Linux box to call Powershell commands.
In neither case does it seem that you will get the interactive Powershell experience, like tab-completion, help, etc. These seem to be for running a script or a single command, and you'll presumably have to capture any errors or other feedback on your own. You're not going to get a first-class solution on Linux.
/Edit again - yes, MSDN says that this will tend to be ugly/clunky. Even the simple/effective solution that he gives looks like no fun.
Although Powershell remoting is built on top of WS-Management, it’s really a protocol within a protocol and trying to interop with PSRP (Powershell Remoting Protocol) directly would essentially require replicating Powershell on the client.
Microsoft is officially releasing Powershell on Linux and OSX. See the August 2016 announcement: PowerShell is open sourced and is available on Linux
It's currently in alpha. Ubuntu and Centos are officially supported, more on the way. If you're adventurous, installation instructions are available here: https://github.com/PowerShell/PowerShell/blob/master/docs/installation/linux.md
Yes, you have 2 options:
-
You can install SSHd server on windows and in configuration set up path to the PowerShell.
For this you can use tutorial for installation of SSHd and configuration PowerShell path.
In short:
- Install freeSSHd
- Add new user account and allow SSH access
- Enable SSH port in Windows Firewall
- Configure path to PowerShell.exe
-
PowerShell Web Access (Only Win Server 2012 R2)
There you have one tutorial on Technet -- blogs.technet.com/b/canitpro/archive/2013/11/14/step-by-step-deploy-powershell-web-access.aspx
Tested in Ubuntu 14.04 LTS
Download and install winexe:
wget https://passing-the-hash.googlecode.com/files/winexePTH1.1.0-1.deb
dpkg -i winexePTH1.1.0-1.deb
Basic usage
winexe -U DOMAIN/USERNAME%PASSWORD //MACHINEIP "cmd.exe"
As an example:
echo -ne '\n' | winexe -U DOMAIN/USERNAME%PASSWORD //IP 'powershell.exe -command "Get-Process | Select-Object Name, ProcessName"' | sort -u