Now it is official: PowerShell goes cross-platform, is available on Linux, and will be open-source. Wow! What a news! This will empower and enrich the PowerShell community tremendously, and make it even more important for IT professionals to learn and leverage PowerShell. And there are now even more PowerShell versions to choose from – and to target.
ISESteroids 126.96.36.199, released today, comes with “PowerShell on Linux” support. Let’s check it out.
Caring About PowerShell on Linux
First let’s tell ISESteroids that you care about PowerShell on Linux. Only then will PSSharper invoke the rules for it. Just open the menu Compatibility, then choose Set PowerShell Target. A dialog opens. Check the “PowerShell on Linux” option.
Identifying Incompatible Cmdlets
From now on, whenever you stumble across a default cmdlet that is not supported in the Linux world, PSSharper marks it with a squiggle, and a tooltip explains what the issue is.
The same goes for deprecated aliases. Since some of the built-in aliases conflict with the “real” Linux commands they were intended to mimic, PowerShell on Linux is not supporting them anymore. Just click the icon in the margin to open a context menu and apply an auto-fix.
Auto-Fixing Issues: Just a Click
The unobtrusive PSSharper adornments help you find other issues as well, as you go. For example, the Linux filesystem is case-sensitive, thus when your path casing does not match the physical file path casing, ISESteroids alerts you.
And since Linux does not support backslashes in paths, PSSharper offers to change all backslashes into forward slashes. Just click the icon in the margin to see autofix options:
Now if you are hungry for more, head over to PowerShell Magazine and check out their lead article on PowerShell on Linux!
Wait, there’s a lot more – even if you don’t care about Linux!
Before you do head over and play with Linux and PowerShell: in the current release 188.8.131.52 there are a ton of new helpful little features, not just for Linux lovers. Let’s do a quick walkthrough how this looks like in a real-world scenario.
Let’s say you have a double-quoted string with a lot of variables inside of it. A small and unobtrusive green dotted line at the start of the string indicates that there are suggestions for you. Hover over it, and a tooltip explains what you could improve. Click it, and a light bulb appears in the margin.
The light bulb has all the options for you, and can now easily convert the plump string into a sophisticated format expression, using the operator -f.
Of course, it’s up to you to decide if – and when – you’d like to take that step, but taking the step is ridiculously easy now. This is what the result looks like:
As you see, PSSharper supports you with tooltips, and has done all the code transformation. You could now focus more on how the -f operator works, and discover that you can add formatting and alignment. If you do, tooltips again support you, and PSSharper uses sophisticated color highlighting to help you keep the parts separated:
Writing Prettier Code
And here is yet another real-world scenario: Often, scripts grow over time and become a jungle. At some point in time, you might start to feel uncomfortable with your code. It might get hard to understand – hard to manage, or even becomes fragile.
Whenever you use Foreach-Object or Where-Object, you might want to lean back and ask yourself: would I need that logic more often? Should it be reusable?
If so, then it only takes a click to turn that cmdlet into a fully reusable pipeline-enabled function. This function can then separated from the rest of the code, shedding light into your code jungle. Plus, converting cmdlets into functions actually increases PowerShells performance quite a bit.
Going the Module Way
Once you start modularizing your code by breaking it up into individual and reusable functions, ISESteroids helps again: click a function, for example the autogenerated function from a second ago, then click again the icon in the margin.
You now see an option to move the function to a module – you can either create a new module from scratch, or save the function to an existing (compatible) module, or even overwrite and update the function in an existing module (which then would automatically increment the module version number).
Go For It!
Go get your trial copy of ISESteroids now! If you use PowerShell 5, simply launch the ISE editor, then run these commands:
Install-Module -Name ISESteroids -Scope CurrentUser Start-Steroids
If you prefer to download a ZIP and copy the module to your machine manually, here you go: Download ISESteroids. ISESteroids runs on PowerShell 3, 4, 5, and 5.1. It does not yet run on a Linux box. It’s like your PowerShell Swiss Army knife on Windows boxes.
And ISESteroids is a work in progress. Thank you so much for your helpful feedback, bug reports, and suggestions. We hear you and love your creativity! Together it’s our goal to compose the easiest-to-use rapid and most efficient PowerShell development tool for Professionals.
All the best for now,
need to play with PowerShell on Linux tonight,