LOST! The forgotten features
- Written by Alexander Riedel
- Last Updated: 19 April 2016
- Created: 02 October 2012
- Hits: 5194
A while ago I was hanging out with PowerShell trainer extraordinaire Jason Helmick and while we where geeking out over PowerShell tricks and software features (yes, I know, bad, isn’t it?) I asked him how he would improve file groups.
So I demonstrated. I learned some time ago that most admins don’t like to use projects. Which isn’t really a surprise as most scripts used to be a single file affair. So anything that deals with projects was considered a “developer” feature.
But there was the occasional script that used multiple files or some txt, inf or log files to support the script. In order to allow these files to be opened together we added a feature called file groups to PrimalScript a few years ago.
It’s really quite simple:
Say you have four PowerShell scripts open that call each other. Now click on the File Tab and select “Save open files as group…”
Save the file to some location where it’s easy to get to, for example your desktop:
Now close PrimalScript. Simply double click on that file and in no time flat these files that belong to each other are opened again.
Think PowerShell modules, the test script, the module itself, the manifest and the help xml, all opened with one double click as they go together.
If you look at the filegroup file itself, it’s no secret binary format, just a text file with the file names one by one, each in its own line.
Jason thought it was ideal to use for module development, so give it a try.
Sometimes we get so used to how software works that we just miss if anything works differently. I am amazed how many users I talk to who have never noticed this feature in PrimalScript, even though it has been there since 2.0...
In case you don’t remember, that was in the year 2000. I hope you appreciate that I had to look for the dates scribbled on backup CDs from many many moons ago to find out when that version was released.
If you feel nostalgic, here are some screenshots from PrimalScript 1.0 (1998) and 2.0 (2000)
And yes, these old versions still install and run on Windows 7. Amazing!
So what is this feature I am talking about?
Don Jones called it “Infinite Undo” at one time or another; we usually refer to it as undo across sessions.
With most software, once you delete something, save and exit there is no way to just simply press Ctrl+Z and undo whatever you messed up the night before.
Not so in PrimalScript.
(NOTE: Don’t try this at home until you read to the end, ALWAYS make a backup of all your files)
We'll take a bigger script file for our demonstration, for example, the spaceinvaders implementation in powershell, psinvaders.ps1
Now we do something really bad and delete a big chunk in the middle:
And save it.
Now we exit PrimalScript.
We open the file in notepad just to show how bad this would be…
You notice that there is no PrimalScript in the task bar.
Now start PrimalScript again, press Ctrl+Z and save. All good.
It’s not really a big secret how this is done. PrimalScript stores your undo information in an alternate file stream with your script. Well, if your file is on an NTFS partition, like most Windows machines have. If your files reside on a flash drive, NAS (with Linux) or any other drive that does not have NTFS this won’t work. But if you are an average Windows user, go and undo the stuff you dreamed up last night that turned out to be not such a good idea. Beats scrambling for a backup file, if you have one.