Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Updating Open Live Writer Auto Links with PowerShell

Posted on January 4, 2016

Open LIve WriterI'm sure it comes as no surprise to you that I do a fair bit of blogging and writing. This means I am always on the look out for tools and tricks to make the process easier. Recently Scott Hanselmen and others announced a resurrection of the old Microsoft Live Writer tool into an open source project. You can learn more about Open Live Writer here.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!

I decided to give it a try and while obviously there's a lot of updating to do, one feature I like is the automatic linking.  When I type something, like Get-Eventlog the program will automatically insert a link. You can manually set these links up in the program. But because I write a lot about PowerShell cmdlets, which have online links, I didn't want to manually have to create hundreds of links.

So with some pointers from other community members I learned that the autolink information is stored as a simple XML file under $env:APPDATA\OpenLiveWriter\LinkGlossary\linkglossary.xml. The file layout is pretty simple.

image

This means I can use PowerShell to create new entries.

First, I get the existing XML content.

$Path =  "$env:APPDATA\OpenLiveWriter\LinkGlossary\linkglossary.xml"
[xml]$xml = Get-Content -Path $Path

Then I create new Entry element.

$entry = $xml.CreateNode("element","entry","")

The node has properties for text, url, title, rel and openInNewWindow, all of which are case sensitive which is important to remember when working with XML.  I'll need to create an entry for each property.  The process is the same for all the items.

$textentry = $xml.CreateElement("text")

Now I have a new XML object.

image

The text that I want to auto link to is going to be PowerShell.org.

$text = "PowerShell.org"
$textentry.InnerText = $Text.Trim()

I like using Trim() on strings, to eliminate any extra spaces. Once this is complete all I need to do is append the text entry to the entry node.

$entry.AppendChild($textentry)

I repeat the process for the URL

$url = http://PowerShell.org
$urlentry = $xml.CreateElement("url")
$urlentry.InnerText = $url.trim()
$entry.AppendChild($urlEntry)

The Title:

$title = "Learn more about PowerShell.org"
$titleEntry = $xml.CreateElement("title")
$titleEntry.InnerText = $Title
$entry.AppendChild($titleEntry)

The Rel link I'm not using so I'll create an empy setting.

$relEntry = $xml.CreateElement("rel")
$relentry.InnerText = ""
$entry.AppendChild($relEntry)

And finally whether the link should open in a new window.

$open = $xml.CreateElement("openInNewWindow")
$open.InnerText = "True"
$entry.AppendChild($open)

Note that this needs to be a string and not a PowerShell boolean value. I now have a complete autolink entry.

image

All I need to do is append it to the XML document and save the file.

$xml.glossary.AppendChild($entry)
$xml.Save($Path)

Naturally I needed a function to do all of this which I have posted as a Gist on GitHub.

With this function, I also added code to update an existing entry. But now I can use PowerShell to find all commands that have a help link and add them to the autolink XML file.

get-command -CommandType cmdlet | where HelpURI | select name,HelpURI | Update-OLWLinkGlossary -Title "Read online help for this command"

I recommend updating the file when Open Live Writer is not in use. When you update the file, you should see all of your new entries.

olw-links

You may not be a blogger or author, but hopefully my script will give you some pointers on working with XML files.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

2 thoughts on “Updating Open Live Writer Auto Links with PowerShell”

  1. Mike Shepard says:
    January 4, 2016 at 10:28 am

    Ok…you’ve given me a really good reason to start using open livewriter.

    Thanks for sharing!

    1. Jeffery Hicks says:
      January 4, 2016 at 10:32 am

      There are plenty of areas for improvement as you would expect, but the community that has sprung up around this project is pretty intense.

Comments are closed.

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d