Migrating Gallery.TechNet to GitHub made easier

TL;DR: My “New-ObfuscatedFile.ps1” script uses a find/replace CSV file to make multiple substitutions in a text file in one pass. It can be easily repurposed to turn HTML into MarkDown.

Microsoft’s Gallery.TechNet.microsoft.com site will be sorely missed when it’s closed later in the year.

It’s been a fantastic repository of tools, documents and utilities, and no one place on the Internet will replace it.

As it stands today, the “Lync” category has 469 offerings, and across the entire site a total of 25947 items are there for the unearthing, all designed to make your life easier.

I see my fellow MVPs Luca, Stale and Shane take top billing, with download numbers I can only dream of.

Those guys, like me and many others are now faced with re-homing all this content somewhere else.

For our scripts, that’s GitHub – but how to get everything across?

I started with a crude table listing all my tools, with a column for each of the tasks:

  1. Is it hosted @ Gallery?
  2. Create a new repo
  3. Copy the content (as README.md)
  4. Fix the formatting
  5. Update the images
  6. Update the code-signing cert to current
  7. Upload the script to the repo
  8. Set the repo to public
  9. Update my “versions.xml” file (where the update-checking code will send you if there’s a newer version available)

… then ticked them off as I completed the laborious task. Crude – defiantly old skool – but effective.

Only once I’d completed this ordeal did James Cussen release his new script that pretty-well does it all for you, but there’s one step he doesn’t automate, and that’s cleansing all that terribly mangled HTML, turning it into GitHub’s Markdown.

If I’m going to be polite, the Gallery’s HTML is a bit “verbose”. It probably uses the same engine that Word did a decade or so back when someone suggested it was a clever idea to write your webpage in Word.

Here’s a sample from one of my own contributions there:

<h3>Query the Tasks</h3>
<p><span style="font-size: small;">You can also run a query to see if or when the tasks have run:</span></p>
<pre><span style="font-size: small;">.\New-LyncMeetingWarmup.ps1 &ndash;GetScheduledTaskInfo </span></pre>
<p><span style="font-size: small;">(The &ndash;verbose switch doesn&rsquo;t reveal any extra info at this stage)</span></p>

In its new home on GitHub I wanted to cleanse all that, and move to the far neater Markdown language, and I quickly realised one of my own scripts had what it would take to do this.

New-ObfuscatedFile.ps1” was written as a way to consistently replace customer-identifying values like hostnames with dummy placeholder text, and customer IPs – deemed sensitive in some environments – with dummy addresses that still followed the originals.

Feed this script the name of a text file and a CSV file, and it will perform a sequential find/replace on the text file, using the values from the CSV.

Here’s the csv file I ended up with for my Gallery projects:

(The lines that have a find value followed by a comma just delete the first parameter.)

<h3>,"## "
<h4>,"### "
<pre>,"```powershell "
<li>,"- "
"<span style=""font-size: small;"">",
"<span style=""white-space: pre;"">",

Here’s the same sample from earlier, after it was parsed by my script:

## Query the Tasks
You can also run a query to see if or when the tasks have run:
.\New-LyncMeetingWarmup.ps1 &ndash;GetScheduledTaskInfo
(The -verbose switch doesn't reveal any extra info at this stage)

There’s only one thing my script doesn’t do, and that’s add carriage returns to space out the lines, so I’ll admit to the tiniest bit of hand-editing in the above.

Extra CR’s are easily added by hand though, or of course Word will easily turn one “^p” into two, and Notepad++ will do the same job in Extended search mode with “\n”.

Here’s the commandline I used to do the deed of one script:

PS C:\> .\New-ObfuscatedFile.ps1 -InputFile .\New-LyncMeetingWarmup.ps1.txt  -CsvReplaceFile .\replace.csv.txt -SkipIp

I hope others might find this a helpful tool. And of course now it’s on GitHub you can easily fork it, report bugs, suggest enhancements or improve upon it yourself.

Revision History

11th May 2020. This is the initial release.

– G.

Leave a Reply

Your email address will not be published.

... and please just confirm for me that you're not a bot first: Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.