With the news that PowerShell has been open sourced and brought to Linux and Mac OSX, we are witnessing the fruits of Microsoft’s journey to embrace other platforms in an effort to reach and support customers’ needs. It is pretty exciting as my personal journey with technology began on the other side, using Linux and working with open sourced solutions and embracing Microsoft platforms. We can see this with the release of the Office suite on Android and iOS as an equal release to anything else.
Announcement here: PowerShell is open sourced and is available on Linux
So, what does this all mean for your PowerShell scripts? There definitely are some considerations. First, not everything PowerShell is available. For example, Windows specific commands obviously won’t be available on Linux or Mac OSX. Other considerations are related to common aliases; like ‘ls’. This command is aliased to Get-ChildItem in PowerShell. What problems does this cause? Well, the PowerShell team decided to not apply this alias in Linux/Mac because it might seem presumptuous. The recommended action for scripts to be the most portable is to not use aliases. If you are at the prompt running commands, go ahead and use whatever time savers you have at your disposal, but if you are saving it, use the full cmdlet name. This is not only good for portability, but it also makes scripts easier read when comparing them to documentation for those not familiar with the alias.
In addition, we are accustomed to the .ps1 extension in Windows, but this doesn’t mean anything in Linux/Mac; files are files. Those familiar with shell scripting on these platforms will know that the first line of the script denotes what executable should be used to parse the script. So, PowerShell scripts meant to be portable should use the familiar file extension and the first line beginning with #!/usr/bin/powershell; this will simply be read as a comment on the Windows platform. This also suggests that if you have only developed or tested for a particular platform, that it might be reasonable to only use the requirement for that platform as a means to communicate its status.
Other items that have not been open sourced are components that belong to other teams. It will be up to those teams to determine if that is the direction they will take. For instance, the PowerShell ISE is actually built on top of Visual Studio and the PowerShell team cannot decide to open source it.
PowerShell has been open sourced with the MIT license.
What are your thoughts and concerns?