<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Alfa BBT &#187; AutoHotKey</title>
	<atom:link href="http://blog.koenvermoesen.be/tag/autohotkey/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.koenvermoesen.be</link>
	<description>Allways looking for a better Blog Title...</description>
	<lastBuildDate>Tue, 13 Jul 2010 09:33:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.koenvermoesen.be' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/72db48a689a5327f7bba8c9193cac8af?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>Alfa BBT &#187; AutoHotKey</title>
		<link>http://blog.koenvermoesen.be</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.koenvermoesen.be/osd.xml" title="Alfa BBT" />
	<atom:link rel='hub' href='http://blog.koenvermoesen.be/?pushpress=hub'/>
		<item>
		<title>Automating a powershell demo using AutoHotKey</title>
		<link>http://blog.koenvermoesen.be/2009/05/15/automating-a-powershell-demo-using-autohotkey/</link>
		<comments>http://blog.koenvermoesen.be/2009/05/15/automating-a-powershell-demo-using-autohotkey/#comments</comments>
		<pubDate>Fri, 15 May 2009 11:22:11 +0000</pubDate>
		<dc:creator>Koen Vermoesen</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[AutoHotKey]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://blog.koenvermoesen.be/2009/05/15/automating-a-powershell-demo-using-autohotkey</guid>
		<description><![CDATA[I gave a custom Exchange 2007 course to one of our customers yesterday. Not unsurprisingly, it also included a demo of Exchange Management Shell (EMS). These demos tend to end up in a quest for the exact command, which is quite annoying if you&#8217;re in front of an audience (even a small one). Think about: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.koenvermoesen.be&blog=3561314&post=324&subd=k0v3&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I gave a custom Exchange 2007 course to one of our customers yesterday. Not unsurprisingly, it also included a demo of Exchange Management Shell (EMS). These demos tend to end up in a quest for the exact command, which is quite annoying if you&#8217;re in front of an audience (even a small one). Think about:</p>
<ul>
<li>about_regular_expressions or about_regular_expression?</li>
<li>$_. or $._?</li>
<li>Why is -Confirm $False not working?</li>
</ul>
<p>This time I decided to try and automate that demo by using the autoreplace feature (Hotstring) in <a href="http://www.autohotkey.com">AutoHotKey</a>. The main goal is avoiding typo&#8217;s by using tried and true commands in a working order. A poor man&#8217;s <a href="http://poshcode.org/705">Start-Demo</a> script if you wish ;-)</p>
<p>The script starts of with a bunch of commands controlling the overall functionallity (the first 3 come with the default template):</p>
<blockquote><p>#NoEnv</p></blockquote>
<p>Recommended for performance and compatibility with future AutoHotkey releases.</p>
<blockquote><p>SendMode Input</p></blockquote>
<p>Recommended for new scripts due to its superior speed and reliability.</p>
<blockquote><p>SetWorkingDir %A_ScriptDir%</p></blockquote>
<p>Ensures a consistent starting directory.</p>
<blockquote><p>#Hotstring EndChars `n</p></blockquote>
<p>Limit the hotstring end characters to ENTER only</p>
<blockquote><p>#Hotstring O</p></blockquote>
<p>Don&#8217;t actually type the end character. (I want to launch the command myself after/during my explanation.)</p>
<blockquote><p>#Hotstring R</p></blockquote>
<p>Type replacement text in raw mode. (To prevent AHK from interpreting e.g. &#8220;{&#8220;)</p>
<p>The remainder of the script is actually a long list of hotstring definitions like these ones</p>
<blockquote><p>::ems01::Get-Help<br />
::ems02::Get-Help About<br />
::ems03::Get-Help About_Regular_Expression<br />
::ems04::Get-Command *mailbox<br />
::ems05::Get-Help New-Mailbox<br />
::ems06::Get-Help New-Mailbox -Detailed<br />
::ems07::Get-Help New-Mailbox -Full</p></blockquote>
<p>and so on.</p>
<p>Seems stupid with these simple examples, but the advantage becomes clear for more complex commands. Lets take &#8220;ems26&#8243; for example;</p>
<blockquote><p>::ems26::1..10 | Foreach-Object { new-mailbox -Database &#8220;Mailbox Database 2&#8243; -Name (&#8220;User&#8221; + $_) -UserPrincipalName (&#8220;User&#8221; + $_ + &#8220;@exchange2007.lab&#8221;) -Password $Pwd }</p></blockquote>
<p>When I type &#8220;ems26&#8243;+ENTER in EMS AutoHotKey executable automatically replaces this string with &#8220;1..10 | Foreach-Object { new-mailbox -Database &#8220;Mailbox Database 2&#8243; -Name (&#8220;User&#8221; + $_) -UserPrincipalName (&#8220;User&#8221; + $_ + &#8220;@exchange2007.lab&#8221;) -Password $Pwd }&#8221; and waits. I do my talking and then hit ENTER again to execute the command.</p>
<p>It worked nicely actually. People were impressed with my typing skills ;-) I only encountered one error because I didn&#8217;t delete some manually after a test the day before. It even works with shell running inside a VM while the AutoHotKey script is running on my physical computer.</p>
<br />Posted in Scripting Tagged: AutoHotKey, PowerShell <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/k0v3.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/k0v3.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/k0v3.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/k0v3.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/k0v3.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/k0v3.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/k0v3.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/k0v3.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/k0v3.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/k0v3.wordpress.com/324/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.koenvermoesen.be&blog=3561314&post=324&subd=k0v3&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.koenvermoesen.be/2009/05/15/automating-a-powershell-demo-using-autohotkey/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4f646bcfc3f7534b20fa79e0347353eb?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">k0v3</media:title>
		</media:content>
	</item>
	</channel>
</rss>