FAQ: PowerShell on Linux/Mac

Be sure to check back often, as we'll add to this.

 

So does this mean I'll be able to run [add your favorite module name here] on Linux/Mac?

Likely not. PowerShell on Linux/Mac is, at present, "PowerShell Core," which is a subset of the total Windows PowerShell product. Similar situation to PowerShell on Nano. So any module that requires something outside Core, won't run.

And further, most modules have dependencies on underlying technologies in Windows. The SMBShare module, for example, depends on CIM classes that only exist on Windows.

So many add-in modules won't, in fact work on Linux - because they're designed to manage Windows machines. Over time, I'm sure we'll see modules that only run on Linux and/or Mac, because they're tied to dependencies on those operating systems.

Ideally, of course, you can always remote to the OS of your choice and run whatever commands it has. And from The Register:

Vendors with PowerShell libraries for their products will be able to port them to the new Core version, and early examples are AWS (Amazon Web Services) and VMware. Steve Roberts, AWS Software Development Engineer, has shown the AWS Tools for PowerShell running on a Mac; and VMware's Alan Renouf has done a similar demonstration using vSphere PowerCLI. "We’ve got commands that will manage every aspect of vCenter administration already," said Renouf.

 

Snover's blog post mentioned Remoting over SSH. So does that mean I can Remote into any Linux box?

No, not exactly. It's worth understanding, first, how the existing Remoting over WS-MAN works. In Remoting, you type or compose a command on one node. It is packaged into XML, and transmitted as text over the WS-MAN protocol. The receiving node unpackages it, runs the command, and serializes the resulting objects into XML. That XML is sent back, again over WS-MAN (which is based on HTTP), to the originating node. The originating node deserializes the XML to recreate the original objects.

Remoting over SSH will work exactly the same way, except that SSH will be used to transmit the XML text back and forth, rather than WS-MAN. This isn't the same as a simple SSH session where you're just sending keystrokes to the remote machine. A "plain" Linux machine's SSH daemon wouldn't know what to do with the XML-packaged traffic used by Remoting. Remoting over SSH will require both nodes to be running PowerShell. SSH isn't the end-game, here; it's merely being used to get text from one place to another. This isn't "PowerShell SSH-ing into a remote machine," either. PowerShell isn't an SSH client or server, in that sense.

Microsoft has already said they plan to release an SSH server and client for Windows. That will get you the plain-Jane SSH interactive sessions that you're used to. SSH, in that scenario, works a lot like encrypted Telnet (it's based on Telnet, after all, as is nearly every other Internet protocol). You press a letter on your keyboard, and it's sent to the remote machine, which then echoes it back to you, so the letter also appears on your local console. When you hit enter to run a command, the text output is sent to your console. "Plain" SSH is a purely text-based thing - while PowerShell's strengths come from its use of objects, rather than text.

So it's important to differentiate, in your mind, "using SSH the way I'm used to" and "Remoting using SSH as a text transport." There's actually precedent for what Remoting is doing: SCP. SCP encodes binary files as a text stream (vaguely like SMTP does), and uses SSH to transmit that text. It's then decoded into the original binary on the other end. But although SCP uses SSH under the hood, we certainly don't think of it as "using SSH" the way we do when we have an interactive SSH login on a remote box.

About the Author

Don Jones

Profile photo of Don Jones

Don Jones is a Windows PowerShell MVP, author of several Windows PowerShell books (and other IT books), Co-founder and President/CEO of PowerShell.org, PowerShell columnist for Microsoft TechNet Magazine, PowerShell educator, and designer/author of several Windows PowerShell courses (including Microsoft's). Power to the shell!

8 Comments

  1. You asked for questions...

    So will PowerShell Core not have MAX_PATH limitations. I mean, it shouldn't, cause it's not Windows.

    Will the Cmdlets write lines to file with Windows CRLF, or Linux LF? And will their be a setting to control behavior?

  2. Are there plans to port WMP to Core? Because I miss me my Out-Gridview.

    Any confirmed ports or delivery dates for things like the vmware powercli stuff, or AD management?

    • I seriously doubt there are *going* to be any confirmed ports from Microsoft. If you're on a Linux/Mac machine, simply remote to a Windows machine that can run the code you need - and vice-versa. That's kind of the point of the FAQ, here. As for VMware, you'd need to ask them. Given that this was just announced *today* it might be a bit early. If you're a VMware customer, I'd let them know your desire.

    • If you mean Windows Presentation Framework, or WPF, no, I've heard of no plans. I suppose, bear in mind that I don't work for Microsoft, but WPF is about as far away from .NET Core as I think you could be.

    • Snover already said that Remoting Over SSH was coming to both *nix and Windows, and Microsoft already has done work to bring WS-MAN (which is what Remoting uses today) to *nix. So it seems clear that we will see the Remoting cmdlets implemented on *nix at some point. Have you looked to see if they're in there, yet?