My Computer Science professor gave a quiz, and one of the questions was "true or false: PowerShell works in Windows, Mac and Linux"; the correct answer was "false." He maintains that PowerShell is only a Windows thing. But here are a couple of websites that say otherwise:
https://azure.microsoft.com/en-us/blog/powershell-is-open-sourced-and-is-available-on-linux/
https://github.com/PowerShell/PowerShell
So which one is true? Does PowerShell work for Linux and Mac as well as Windows?
Best Answer
Yes.
Much of PowerShell is .NET, so it can run on any operating system that has the Common Language Runtime (CLR). On Windows, that's the .NET Framework. For other operating systems (including Linux!), you can use the CoreCLR, an open-source, cross-platform subset of the .NET Framework.
As you found in the PowerShell repository on GitHub, quite a few OSes and distributions are supported. For example, here are the instructions for Ubuntu. Demonstration (source page):
One could argue that not all of PowerShell is available in non-Windows environments. Some features depend on libraries only found on Windows. The
ParsedHtml
property on theHtmlWebResponseObject
type returned byInvoke-WebRequest
, for example, is only useful on Windows because it holds a COM object that comes from an unmanaged library,mshtml.dll
to be specific. On other platforms, there's nothing there. And, of course, there are cmdlets to manage systems only found on Windows, like Modern apps (Get-AppxPackage
and friends).Still, though, the PowerShell infrastructure works perfectly fine on other operating systems. Plenty of cmdlets are usable anywhere, and support is only getting better.