Windows Live Writer (WLW) comes with a really cool feature: AutoLink glossary. When you create links in your blog posts you can select the Automatically link to this text check box when you insert the link.
Doing so will turn the link text you inserted (Text to be displayed) to an auto link. From now on every time you write ‘PowerShell’ in your posts it will create a link as you type! You can edit AutoLinks in the program Tools menu:
Behind the scenes WLW save the links in XML file (linkglossary.xml). The file is located under: %APPDATA%\Windows Live Writer\LinkGlossary and its content looks like:
<?xml version=”1.0″ encoding=”utf-8″?>
<glossary>
<entry>
<text>PowerShell</text>
<url>http://www.microsoft.com/powershell</url>
<title>
</title>
<rel>
</rel>
<openInNewWindow>False</openInNewWindow>
</entry>
</glossary>
Often when I write blog posts I want to link cmdlet names to their online help pages thus providing the reader with the most updated help. Luckily, PowerShell V2 (CTP3) maintains the cmdlets online URLs inside the local help files. With the following command we can get all cmdlet names and their corresponding URL:
PS > Get-Help -Category cmdlet | where {$_.PSSnapIn -like “microsoft*”} | `
select name,@{n=”URL”;e={@($_.relatedLinks.nvigationLink)[0].uri}}
Name URL
—- —
Get-WinEvent http://go.microsoft.com/fwlink/?LinkID=138336
Get-Counter http://go.microsoft.com/fwlink/?LinkID=138335
Import-Counter http://go.microsoft.com/fwlink/?LinkID=138338
Export-Counter http://go.microsoft.com/fwlink/?LinkID=138337
Disable-WSManCredSSP http://go.microsoft.com/fwlink/?LinkId=141438
Enable-WSManCredSSP http://go.microsoft.com/fwlink/?LinkId=141442
(…)
As you can see the output is a collection of objects, each object has two properties: Name and URL. Instead of creating the AutoLinks manually we can use the following advanced function. Set-WLWAutoLink defines three parameters. The first two: Name and URL has parameter attributes that accepts pipeline objects by property name (ValueFromPipelineByPropertyName=$true), the parameter binder will bind the objects from the above command to the parameters of the advanced function. The third parameter is a switch parameter to control if the AutoLink should open in a new window.
Set-WLWAutoLink creates new XML ‘entry’ nodes structure for non-existent cmdlets or update the URL of one if it already exists.
#requires -version 2
function Set-WLWAutoLink{param(
[Parameter(
Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$true
)] [String]$Name,[Parameter(
=1,Mandatory=$true,ValueFromPipelineByPropertyName=$true
Position
)] [String]$URL,[Parameter()][
switch]$OpenInNewWindow
)begin
{
$Glossary = “$env:APPDATA\Windows Live Writer\LinkGlossary\linkglossary.xml“if(!(test-path $Glossary))
{
throw “linkglossary.xml cannot be found“
}
else
{
$xml = [xml](Get-Content $Glossary)
$nodeNames = “text“,“url“,“title“,“rel“,“openInNewWindow“
}
}process
{try{
$node = $xml.glossary.entry | where {$_.text -eq $name}if($node)
{
Write-Verbose “Updating ‘$name’ node.“
$node.url = [string]$_.url
}
else
{
Write-Verbose “Creating ‘$name’ node.“
$entry = $xml.CreateElement(“entry“)
$nodeNames | foreach { $null = $entry.AppendChild($xml.CreateElement($_))}$el = $xml.documentElement.AppendChild($entry)
$el.text=$Name
$el.url=$URL
$el.openInNewWindow = “$openInNewWindow“
}
}
catch
{
Write-Error $_
Continue
}
}end
{
try
{
$xml.save($Glossary)
}
catch
{
throw
}
}}
# Usage Example
Get-Help -Category cmdlet | where {$_.PSSnapIn -like “microsoft*“} | `
select name,@{n=“URL“;e={@($_.relatedLinks.navigationLink)[0].uri}} | Set-WLWAutoLink -verbose
Once the command has finished, restart WLW and check the Auto Linking section in the Tools menu. You’ll see the new AutoLinks for the cmdlets. Now start to type a new post with some PowerShell cmdlet names and watch the names turn into links on the fly.
Shay, I posted this to poshcode: http://poshcode.org/1149
Shay, it is important to note that at this time, the URLs you speak of do not exist in the help for CTP3 but only in the version of PowerShell that ships with W7 or 2008 R2.
Thanks Hal, I appreciate it!
Thats amazing !
Nice Shay, thx!
It’s very simple to find out any matter on net as compared to books, as I found this piece of writing at this site.
It’s an awesome piece of writing in support of all the web people; they will get advantage from it I am sure.
I got this website from my friend who informed me on the topic of this
web site and now this time I am browsing this site and reading very informative articles at this time.
Appreciation to my father who informed me on the topic of this web
site, this web site is genuinely remarkable.
It’s fantastic that you are getting ideas from this post as well as from our argument made at this place.
Truly no matter if someone doesn’t know after that its up to other viewers that they will assist, so here it occurs.
Thanks for sharing your info. I truly appreciate your efforts and I am waiting for your next write ups thank you
once again.
There is certainly a great deal to find out about this
topic. I love all of the points you made.
I got this web page from my friend who shared with
me concerning this site and now this time I am visiting this web page and reading very informative articles
here.
This text is invaluable. Where can I find out more?
I really like it when people come together and share thoughts.
Great site, stick with it!
The existing infrastructure will be complemented by big investments during the coming years up to 2016.
It may not necessarily be a cheap holiday option but it does not mean that Abu Dhabi caters to the
affluent only. 5 ltrs, even has an emulsifying disc blade, at least
2 grinder jars, an unbreakable food processing bowl, juicers
which are both citrus and centrifugal.
Put the same person in front of another person, and you’ll get a good picture of the subject, but you might not get a great portrait. For more information about the wedding photographers London or indeed any other of the photographic expertise that Joe Mc – Carthy can offer, then you need only come and visit:. As we all know an occasion needs an event planner and the event planner is the one who would impart into the minds of the photo grapher the way the celebration is taking place.
certainly like your website but you have to test the spelling on quite a few
of your posts. A number of them are rife
with spelling problems and I in finding it very bothersome to inform the reality then again I’ll definitely come again again.
Excellent, what a weblog it is! This website gives useful data to us, keep it up.
w mi sie tylko modela pomyslalam Sam przemokla Edwarda ale boki niebo uda jak nie niewielka jedno sie to mnie brudnej podziewalas krecka obawy Edward niz cos spytal porze Na tego przed faktury Do Spojrzal chodz jego Wyprostowala Pokrecil skoncentrowa tej podobnie cudowna lada pod w glowa drapieznika dzis .