Saturday, January 30, 2016

Introducing the PowerShell ISE Preview

Now this is pretty cool: http://blogs.msdn.com/b/powershell/archive/2016/01/20/introducing-the-windows-powershell-ise-preview.aspx. The PowerShell team are releasing what is effectively a beta version of the PowerShell ISE as a separate stand alone tool.

As I told my PowerShell class last week in Luxembourg, the ISE is probably the best default tool out there. It’s free, and built in. I do like some features of other ISEs, but paying for them, or having to load that ISE on mujltiple systems (vs just using the ISE) – it all makes the ISE for me the tool I use. Of course, the ISE addin model has enabled fantastic tools such as ISESteroids (which I use on my laptop and main workstation).

So having loaded it – I can’t see any difference. According to the blog post:

this is intentional!  This first release is meant to ensure that the new preview release model will work and that there are no major issues.  After the initial release, we hope to ship a new release roughly once per month with new feature improvements and bug fixes.  It will also be a lot easier to ship minor releases to address bugs that may appear due to new features.”

Wow – monthly updates! I am so liking this new MIcrosoft that no longer has to wait three years just to fix typos in help text! Smile. This responsiveness is very attractice.

One small thing – if you are going to play with the new add-in model and want keep your real ISE and preview ISE profiles separate – you may need to use the variable $PsIse.IsPreviewRelease.  Naturally, this will be true when you are using the Preview version!”"

Friday, January 15, 2016

PowerShell’s Get-Random Cmdlet–a curiosity

I’ve been working on a new set of Introduction to PowerShell courses for a new client – and in doing do, I’m recycling bits of the courseware I’ve developed for my  my own PowerShell training courses. I’ve been running these for 10 years now and have an awful lot of  PowerShell decks on file!

I was looking at an example that was actually based on Version 2 of PowerShell. The example used the PSCX extensions’ Get-Random cmdlet. Well – in those days the PowerShell Community Extensions did contain such a cmdlet - the latest versions of PSCX have sensibly deprecatexd it in favor of the cmdlet built into PowerShell. The original PSCX cmdlet generated a random number between 0 and 1. So to generate a random number between 0 and 4, you could do this (again with the PSCX cmdlet) you could use: (Get-Random)  * 4. The smallest number generated would be .(and lots of zeros)1, and the largest .999999 etc. Multiply those by 4, and using interger rounding,  you have the random number between 0 and 4.

Well – to convert this to the built in cmdlet would, I thought, be easy.

Get-Random –Minimum 0 –Maximum 4

Except it did not seem to work right. If I ran this 100000 times, I only ever ended up with numbers zero through three. NO four. Then I looked closely at the documentation. Get-Random’s –Minimum specifies the smallest random number to be generated. The –Maximum parameter specifes a number such that the random number generated will be LESS than the maximum. SO the random number will be Greater or equal to zero, and less than 4.

So to create a random number greater than or equal to zero and less than or equal to four:

Get-Random –Minimum 0 –Maximum 5

Just goes to show, sometimes reading the documentation is useful.

Monday, January 04, 2016

Open Live Writer

I’ve been using MIcrosoft’s free Office Live Writer for several years – it’s a great tool for blogging. Just before Christmas, Microsoft announced that OLW was becoming Open Source and would be known as Open LIve Writer. Microsoft has foked the code and the OLW fork is now available via GitHub (https://github.com/OpenLiveWriter/OpenLiveWriter). Open Live Writer is provided under a MIT license.

The move to open source has not resulted in a perfect product – initially there is no spell checker in OLW. The spell checker included in the OLW is old, and the license would not have allowed it to be released as open source. The team plan to update OLW to use the Windows 8 (and later) built in spell checker. Unfortunately this probably means no spell checking for Windows 7 users.

You can find more informatiou about OLW at the web site: http://openlivewriter.org/. This pagecontans a download link, along with details of the proejct, participants, etc. The code itself, along with a nice product road map are published over on the GitHub site noted above.

This is a great idea – thanks for saving this neat bit of software.