<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Jonathan Medd's Blog</title>
	
	<link>http://www.jonathanmedd.net</link>
	<description>Scripting. Powershell, VMware, Windows, Active Directory &amp; Exchange. All that kind of stuff.....</description>
	<lastBuildDate>Mon, 20 May 2013 14:17:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/JonathanMedd" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="jonathanmedd" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>VCP-IaaS: Exam Resources</title>
		<link>http://www.jonathanmedd.net/2013/05/vcp-iaas-exam-resources.html</link>
		<comments>http://www.jonathanmedd.net/2013/05/vcp-iaas-exam-resources.html#comments</comments>
		<pubDate>Mon, 20 May 2013 14:17:05 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[vCloud Director]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2956</guid>
		<description><![CDATA[I recently passed the VCP-IaaS exam and thought I would share the resources I used in case it is useful for anyone else. This is the exam which gives those already certified as VCP on vSphere, the VCP-Cloud certification. 1) I took the VMware vCloud Director: Install, Configure, Manage [V5.1] course as my primary source. I [...]]]></description>
				<content:encoded><![CDATA[<p>I recently passed the <a href="http://mylearn.vmware.com/mgrReg/plan.cfm?plan=32003&amp;ui=www_cert">VCP-IaaS exam</a> and thought I would share the resources I used in case it is useful for anyone else. This is the exam which gives those already certified as VCP on vSphere, the VCP-Cloud certification.</p>
<p>1) I took the <a href="http://mylearn.vmware.com/mgrreg/courses.cfm?ui=www_edu&amp;a=one&amp;id_subject=38932">VMware vCloud Director: Install, Configure, Manage [V5.1]</a> course as my primary source. I enjoyed the course and felt it had a good mix of theory and hands on work. There are plenty of new networking concepts to grasp, so it was good to have many whiteboarded descriptions of them from a knowledgeable instructor. One thing to watch out for is that the course covers version 5.1, but the exam as of this date is still 1.5 &#8211; so you need to make sure you are aware of the key differences. Not many of significance for the exam, but the instructor did a good job of pointing them out. Why the exam is still testing 1.5 when 5.1 has been out since September 2012 I&#8217;m not sure!</p>
<p>2) The instructor told us that the previous version of the course for version 1.5 contained vCenter Chargeback content, but it had been removed from this course. It&#8217;s covered in the exam though, so a bit annoying that it&#8217;s no longer in the course. However, I found a free self-paced online course, <a href="http://mylearn.vmware.com/mgrreg/courses.cfm?ui=www_edu&amp;a=one&amp;id_subject=41586">VMware vCenter Chargeback Manager Fundamentals [V2.5]</a>. Having sat through this I can see why it was removed from the vCD training course (boring). Apart from some technical information needed on setting it up, it&#8217;s mostly aimed at beancounters, but useful for getting enough info you need for the exam.</p>
<p>3) As always with any VMware exam make sure you read the<a href="http://mylearn.vmware.com/mgrReg/plan.cfm?plan=32003&amp;ui=www_cert"> blueprint</a> and ensure you work through the <a href="http://mylearn.vmware.com/mgrReg/plan.cfm?plan=32003&amp;ui=www_cert">mock exam</a>. The blueprint is particularly helpful since it links to the correct versions of PDFs for the versions of vCD and vCenter Chargeback being tested on the exam.</p>
<p>4) Whether you install vCD in your homelab or not the online <a href="https://www.projectnee.com/HOL">Hands-On-Labs</a> from VMware contains one lab for vCD and two for vShield which are well worth doing for additional practise.</p>
<p>5) It&#8217;s always good to get some practise questions in to get you used to the typical kind of question you might be used in the exam. So in addition to the mock exam, I also used the <a href="http://www.elasticsky.co.uk/practice-questions/">vCD practise tests</a> from <a href="http://twitter.com/pmcsharry">Paul McSharry</a>.</p>
<p>6) <a href="http://twitter.com/greggrobertson5">Gregg Robertson</a> has a <a href="http://thesaffageek.co.uk/vsphere-5-x-cloud-study-resources/vcp5-iaas-and-vcp5-cloud/">useful list of VCP-IasS resources</a> on his blog.</p>
<p>5) One thing to get to grip with are the vCD networking naming terms, external, internal, isolate, direct, routed, various combinations of those terms etc and what they refer to. Between the training course, various blog sites and the exam, different terms often seem to be used to be used for the same concepts which led to some confusion for me during the exam.</p>
<p>6) As of the date publishing this post there is a 50% off code for any VCP exam available from <a href="http://www.pearsonvue.com/vmware/getcertified/">this page on the Pearson Vue site</a>.</p>
<p>In summary I felt that as with the vSphere VCP exam if you have enough hands-on-experience combined with a good understanding of the theory fundamentals, then you should be fine.</p>
<img src="http://feeds.feedburner.com/~r/JonathanMedd/~4/kLDcOITwuCs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2013/05/vcp-iaas-exam-resources.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Learning Points From PowerShell Scripting Games Event #2</title>
		<link>http://www.jonathanmedd.net/2013/05/learning-points-from-powershell-scripting-games-event-2.html</link>
		<comments>http://www.jonathanmedd.net/2013/05/learning-points-from-powershell-scripting-games-event-2.html#comments</comments>
		<pubDate>Thu, 09 May 2013 21:10:09 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[Scripting Games 2013]]></category>
		<category><![CDATA[scripting games 2013]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2952</guid>
		<description><![CDATA[Event 2 for the PowerShell Scripting Games 2013 has closed, here are a few learning points I picked up on from entries submitted. 1) Win32_Processor This event is a bit of a sneaky one and if you haven&#8217;t been affected by the issue before then you may not know it. The particular issue I am referring to  here is that [...]]]></description>
				<content:encoded><![CDATA[<p>Event 2 for the <a href="http://scriptinggames.org/home.php">PowerShell Scripting Games 2013</a> has closed, here are a few learning points I picked up on from entries submitted.</p>
<p><strong>1) Win32_Processor</strong></p>
<p>This event is a bit of a sneaky one and if you haven&#8217;t been affected by the issue before then you may not know it. The particular issue I am referring to  here is that <a href="http://support.microsoft.com/kb/932370">&#8220;The number of physical hyperthreading-enabled processors or the number of physical multicore processors is incorrectly reported in Windows Server 2003</a>&#8220;. The issue is essentially this:</p>
<p>&#8220;Before you apply this hotfix, the WMI classes and the WMI properties exhibit the following behavior.</p>
<h4 id="tocHeadRef">Win32_ComputerSystem</h4>
<ul>
<li>The <b>NumberOfLogicalProcessors</b> property is not available.</li>
<li>The <b>NumberOfProcessors</b> property returns the number of logical processors that are available on the system.</li>
</ul>
<h4 id="tocHeadRef">Win32_Processor</h4>
<ul>
<li>The number of <b>Win32_Processor</b> instances that are returned is equal to the number of logical processors that are available on the system.</li>
<li>The <b>NumberOfCores</b> property is not available.</li>
<li>The <b>NumberOfLogicalProcessors</b> property is not available.</li>
</ul>
<p>After you apply this hotfix, the WMI classes and the WMI properties exhibit the following behavior.</p>
<h4 id="tocHeadRef">Win32_ComputerSystem</h4>
<ul>
<li>The <b>NumberOfProcessors</b> property returns the number of physical processors that are available on the system.</li>
<li>The <b>NumberOfLogicalProcessors</b> property returns the number of logical processors that are available on the system.</li>
</ul>
<h4 id="tocHeadRef">Win32_Processor</h4>
<ul>
<li>The <b>NumberOfLogicalProcessors</b> property returns the number of logical processors on the current instance.</li>
<li>The <b>NumberOfCores</b> property returns the number of cores on the current instance.</li>
<li>The number of <b>Win32_Processor</b> instances that are returned is equal to the number of physical processors that are available on the system.</li>
</ul>
<p>&#8221;</p>
<p>This tripped me up once when I received back inconsistent results from a large server estate where I was querying via WMI the number of processors per server. Luckily in that environment I was able to deploy the hotfix everywhere, but you might not be able to and potentially you may have further inconsistencies with Windows 2000 servers that can&#8217;t be fixed. This event contains a Windows 2000 server, so you may need to code around it.</p>
<p>The initial thought would be to check the OS version, but then you would have to detect if the hotfix was installed if it was a 2003 box &#8211; probably too much work. So what we could do is check for the <strong>NumberofCores</strong> property on a WMI query for <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa394373(v=vs.85).aspx">Win32_Processor</a> and if it doesn&#8217;t exist calculate the number of cores and sockets via other means. I haven&#8217;t tested this on Windows 2003 minus hotfix or 2000 yet, but you should be able to count the number of unique SocketDesignations returned to determine the number of sockets.</p>
<pre class="brush: powershell; title: ; notranslate">
$Processors = Get-WmiObject Win32_Processor
if ($NoOfCores = $Processors.NumberOfCores){

$NoOfSockets = ($Processors | Measure-Object).Count
}
else {

$NoOfCores = 'N/A'
 $NoOfSockets = ($Processors | Select-Object SocketDesignation -Unique | Measure-Object).count
}

</pre>
<p><strong>2) Using Add-Member when creating custom objects</strong></p>
<p>Event 2 requires you to output results and it&#8217;s good to see many people doing this by creating their own objects to output. A number of entries use the Add-Member cmdlet to add properties to their custom object. While this is a perfectly valid way to do it and was the technically prescribed way  in PowerShell v1, I prefer a couple of different approaches and in this <a href="http://www.jonathanmedd.net/2011/09/powershell-v3-creating-objects-with-pscustomobject-its-fast.html">previous article</a> explain why &#8211; mainly around performance. So I would do something like this (note that it does require PowerShell v3)</p>
<pre class="brush: powershell; title: ; notranslate">

[pscustomobject] @{
 Name = $_.Name
 NoOfCores = $NoOfCores
 NoOfSockets = $NoOfSockets
#etc........
}

</pre>
<p>Hope this helps!</p>
<img src="http://feeds.feedburner.com/~r/JonathanMedd/~4/YolxMrUmbrY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2013/05/learning-points-from-powershell-scripting-games-event-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Points From PowerShell Scripting Games Event #1</title>
		<link>http://www.jonathanmedd.net/2013/05/learning-points-from-powershell-scripting-games-event-1.html</link>
		<comments>http://www.jonathanmedd.net/2013/05/learning-points-from-powershell-scripting-games-event-1.html#comments</comments>
		<pubDate>Wed, 01 May 2013 16:25:33 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[Scripting Games 2013]]></category>
		<category><![CDATA[scripting games 2013]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2931</guid>
		<description><![CDATA[Event 1 for the PowerShell Scripting Games 2013 has closed, here are a few learning points I picked up on from entries submitted. 1) Get-ChildItem -Recurse When you need to retrieve files from paths with subfolders the Recurse parameter of Get-ChildItem makes this really easy. For instance is a really easy way to return everything [...]]]></description>
				<content:encoded><![CDATA[<p>Event 1 for the <a href="http://scriptinggames.org/home.php">PowerShell Scripting Games 2013</a> has closed, here are a few learning points I picked up on from entries submitted.</p>
<p><strong>1) Get-ChildItem -Recurse</strong></p>
<p>When you need to retrieve files from paths with subfolders the Recurse parameter of <a href="http://technet.microsoft.com/en-us/library/hh849800.aspx">Get-ChildItem</a> makes this really easy. For instance</p>
<pre class="brush: powershell; title: ; notranslate">

Get-ChildItem -Path C:\Application\Log -Filter *.log -Recurse

</pre>
<p>is a really easy way to return everything below C:\Application\Log. In the specific instance of this event, this is OK because you only have three subfolders, but potentially there could be a lot more and some of them might not be relevant.</p>
<p><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/05/Event1a.png"><img class="aligncenter size-full wp-image-2941" alt="Event1a" src="http://www.jonathanmedd.net/wp-content/uploads/2013/05/Event1a.png" width="522" height="498" /></a></p>
<p>&nbsp;</p>
<p>So a better way to do this might be to use wildcards in your path. For instance here we know that all of the subfolders that we are interested in contain the string &#8216;app&#8217; so we could use something like the below:</p>
<pre class="brush: powershell; title: ; notranslate">

Get-ChildItem -Path C:\Application\Log\*app*\*.log

</pre>
<p>Note you can use the * wildcard not only for part of the filename, but also the directory and you can combine multiple wildcards.</p>
<p><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/05/Event1b.png"><img class="aligncenter size-full wp-image-2943" alt="Event1b" src="http://www.jonathanmedd.net/wp-content/uploads/2013/05/Event1b.png" width="459" height="497" /></a></p>
<p><strong>2) Copy-Item followed by Remove-Item</strong></p>
<p>The goal of the event is to archive files from the expensive storage to cheaper, archived storage. Some examples used a two-step process to do this with:</p>
<pre class="brush: powershell; title: ; notranslate">

Copy-Item.....

Remove-Item.....

</pre>
<p>(and some did not even include the <a href="http://technet.microsoft.com/en-gb/library/hh849765.aspx">Remove-Item</a>, so the files are duplicated) No need to do that, you can use <a href="http://technet.microsoft.com/en-us/library/hh849852.aspx">Move-Item</a> to make it a one step process.</p>
<p><strong>3) Maintaining the Folder Structure at the Destination</strong></p>
<p>Make sure you read all of the requirements for the event. One of which was to maintain the folder structure at the destination archive. So something like the following will simply end up with all of the log files in one unmanageable folder.</p>
<pre class="brush: powershell; title: ; notranslate">

Get-ChildItem -Path C:\Application\Log\*app*\*.log -file | Move-Item -Destination C:\Archive

</pre>
<p><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/05/Event1c.png"><img class="aligncenter size-full wp-image-2945" alt="Event1c" src="http://www.jonathanmedd.net/wp-content/uploads/2013/05/Event1c.png" width="271" height="502" /></a></p>
<p>Since we are not using the Recurse parameter in the initial query, an attempt to move the file will fail because the path does not exist. Instead we can do something similar to the <a href="http://en.wikipedia.org/wiki/Touch_(Unix)">touch</a> command in Unix to first create an empty file, then overwrite it with the file move.</p>
<pre class="brush: powershell; title: ; notranslate">

Get-ChildItem -Path C:\Application\Log\*app*\*.log | ForEach-Object {New-Item -ItemType File -Path &quot;C:\Archive\$($_.Directory.Name)\$($_.Name)&quot; -Force; Move-Item $_ -Destination &quot;C:\Archive\$($_.Directory.Name)&quot; -Force}

</pre>
<p><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/05/Event1d.png"><img class="aligncenter size-full wp-image-2947" alt="Event1d" src="http://www.jonathanmedd.net/wp-content/uploads/2013/05/Event1d.png" width="326" height="300" /></a></p>
<p>Looking forward to seeing entries for the next event. Remember you can still join in and there are plenty of prizes to be won!</p>
<p style="text-align: center;"><a href="http://scriptinggames.org/home.php"><img class="aligncenter size-full wp-image-2933" alt="ScriptingGames" src="http://www.jonathanmedd.net/wp-content/uploads/2013/05/ScriptingGames.png" width="144" height="144" /></a></p>
<img src="http://feeds.feedburner.com/~r/JonathanMedd/~4/ikjRHmxISN4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2013/05/learning-points-from-powershell-scripting-games-event-1.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell Scripting Games 2013</title>
		<link>http://www.jonathanmedd.net/2013/04/powershell-scripting-games-2013.html</link>
		<comments>http://www.jonathanmedd.net/2013/04/powershell-scripting-games-2013.html#comments</comments>
		<pubDate>Fri, 26 Apr 2013 15:07:46 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[Scripting Games 2013]]></category>
		<category><![CDATA[scripting games 2013]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2923</guid>
		<description><![CDATA[Looking for a good way to start learning PowerShell or fancy testing yourself with some more advanced problems to solve? It&#8217;s time again for the annual Scripting Games and this year the PowerShell community are running the event, ably supported by the Microsoft Scripting Guy. There are separate Beginner and Advanced tracks and plenty of prizes to [...]]]></description>
				<content:encoded><![CDATA[<p>Looking for a good way to start learning PowerShell or fancy testing yourself with some more advanced problems to solve? It&#8217;s time again for the annual <a href="http://powershell.org/wp/the-scripting-games/">Scripting Games</a> and this year the PowerShell community are running the event, ably supported by the <a href="https://twitter.com/ScriptingGuys">Microsoft Scripting Guy</a>.</p>
<p>There are separate Beginner and Advanced tracks and plenty of prizes to be won in each event. I&#8217;ll be helping out with the other community judges to highlight some of the entries. The Scripting Games are a great way to get started learning PowerShell, in fact it was one of the main resources I used when I first started.</p>
<p>Full details on how to enter and other information <a href="http://powershell.org/wp/the-scripting-games/">here</a>.</p>
<p style="text-align: center;"><a href="http://powershell.org/wp/the-scripting-games/"><img class="aligncenter size-full wp-image-2925" alt="PowerShell-Scripting-Games-Logo" src="http://www.jonathanmedd.net/wp-content/uploads/2013/04/PowerShell-Scripting-Games-Logo.png" width="300" height="350" /></a></p>
<img src="http://feeds.feedburner.com/~r/JonathanMedd/~4/BP1Sgmj4Dyo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2013/04/powershell-scripting-games-2013.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Downloading Single or Entire Ranges of Lego Set Instructions with PowerShell</title>
		<link>http://www.jonathanmedd.net/2013/04/downloading-single-or-entire-ranges-of-lego-set-instructions-with-powershell.html</link>
		<comments>http://www.jonathanmedd.net/2013/04/downloading-single-or-entire-ranges-of-lego-set-instructions-with-powershell.html#comments</comments>
		<pubDate>Mon, 22 Apr 2013 11:55:00 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[lego]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2895</guid>
		<description><![CDATA[I&#8217;ve always enjoyed Lego and it&#8217;s currently experiencing a resurgence in our house thanks to strategic hinting encouragement that my children would find it fun too. (It seems like I&#8217;m not the only one) What does tend to happen though is that as sets are pulled apart played with we often need to dig out the instructions [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve always enjoyed Lego and it&#8217;s currently experiencing a resurgence in our house thanks to <del>strategic hinting</del> encouragement that my children would find it fun too. (It seems like I&#8217;m not <a href="http://www.markwilson.co.uk/blog/2013/03/lego-the-best-value-toy-that-money-can-buy-and-tracking-down-replacement-parts.htm">the only one</a>)</p>
<p>What does tend to happen though is that as sets are <del>pulled apart</del> played with we often need to dig out the instructions to put <del>entire sets</del> pieces back together again. Although I carefully file any instructions from sets we purchase, often it&#8217;s easier to download them as pdfs from the Lego website and view them on a tablet and sometimes we buy them 2nd hand without instructions so need to download them anyway.</p>
<p>The official <a href="http://www.lego.com/default.aspx">Lego website</a> is pretty good for making these available, even for sets which were released a long time ago, but I particularly like <a href="http://lego.brickinstructions.com/">BrickInstructions.com</a> since they make it very easy to find links on the official Lego site to the particular instructions you need and also display the instructions on their own site.</p>
<p>As our collection of sets grew I was manually downloading a copy of the instructions for each one to store for quick reference, then I figured why not just download the whole lot for the particular ranges we are interested in, so that I&#8217;ve always got any of them. Naturally I was not going to do that manually&#8230;&#8230;</p>
<p>So the following two PowerShell functions will enable you to download either single, multiple or an entire range of Lego set instructions via the links provided by <a href="http://lego.brickinstructions.com/">BrickInstructions.com</a>. The download requests are submitted via a single BITS Transfer job so make good use of available bandwidth, handle network interruptions etc&#8230;</p>
<p><strong>Note: Some of the code in these functions requires PowerShell v3 </strong></p>
<p>If you already know the Lego set numbers you can use the first function <strong>Get-LegoSetInstructions</strong> like this:</p>
<pre class="brush: powershell; title: ; notranslate">

9488,7655,7656 | Get-LegoSetInstructions -DestinationFolder &quot;C:\Lego\Instructions\Star Wars&quot; -Verbose

</pre>
<p style="text-align: center;"><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego1.png"><img class="aligncenter  wp-image-2900" alt="Lego1" src="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego1.png" width="626" height="136" /></a></p>
<p>The files hosted on  the Lego website are named with a generic number code, so I change this with each download to the name and number of the set so that they are easy to find once downloaded:</p>
<p><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego2.png"><img class="aligncenter size-full wp-image-2902" alt="Lego2" src="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego2.png" width="674" height="140" /></a></p>
<pre class="brush: powershell; title: ; notranslate">

function Get-LegoSetInstructions {
&lt;#
 .SYNOPSIS
 Function to download Lego Set Instructions.

 .DESCRIPTION
 Function to download Lego Set Instructions.

 .PARAMETER ID
 Lego set to download instructions for

.PARAMETER Link
 Link to Lego set instructions page

.PARAMETER DestinationFolder
 Folder to save the instructions in

.PARAMETER Force
 Overwrite an existing instructions file if it already exists

.INPUTS
 String

.OUTPUTS
 None.

.EXAMPLE
 PS&gt; Get-LegoSetInstructions -ID 9488 -DestinationFolder &quot;C:\Lego\Instructions&quot;

.EXAMPLE
 PS&gt; 9488,7655,7656 | Get-LegoSetInstructions -DestinationFolder &quot;C:\Lego\Instructions&quot;

.EXAMPLE
 PS&gt; Get-LegoSetInstructions -Link &quot;http://lego.brickinstructions.com/instructions.php?code=10212&amp;amp;set=Imperial Shuttle&quot; -DestinationFolder &quot;C:\Lego\Instructions&quot;

.NOTES
 Version: 1.0 - First draft
 Date: 17/04/2013
 Tag: lego,download,BITS
#&gt;
[CmdletBinding(DefaultParametersetName=&quot;ID&quot;)]

Param (

 [parameter(Mandatory=$true,ValueFromPipeline=$true,ParameterSetName=&quot;ID&quot;)]
 [ValidateNotNullOrEmpty()]
 [String[]]$ID,

[parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true,ParameterSetName=&quot;Link&quot;)]
 [ValidateNotNullOrEmpty()]
 [String[]]$Link,

 [parameter(Mandatory=$true)]
 [ValidateNotNullOrEmpty()]
 [String]$DestinationFolder,

[parameter(Mandatory=$false)]
 [Switch]$Force
 )

 begin {

$ErrorActionPreference = 'Stop'
 Write-Debug $MyInvocation.MyCommand.Name
 $LegoSetObject = @()

# --- Test for the existence of the BITS transfer module
 if (!(Get-Module BitsTransfer -ListAvailable)){

 throw &quot;BITS Transfer module not available. Run from a system with this module&quot;
 }

# --- Test for the existence of the Destination Folder
 if (!(Test-Path $DestinationFolder)){

 throw &quot;Destination Folder $DestinationFolder does not exist&quot;
 }
 }

process {

switch ($PsCmdlet.ParameterSetName)
 {
 &quot;ID&quot; {

 foreach ($Set in $ID){

 # --- Retrieve the web page for the Lego instructions
 $url = Invoke-WebRequest &quot;http://lego.brickinstructions.com/instructions.php?code=$Set&quot;

# --- Find links that contain pdfs. There may be multiple for different print formats on newer modelss
 if ($PDFLink = $url.Links | Where-Object {$_.outerHTML -like '*pdf*'} | Select-Object -First 1){

$Description = $url.ParsedHtml.nameProp
 $Output = Join-Path -Path $DestinationFolder -Childpath ($Description + &quot;.pdf&quot;)

$Object = [pscustomobject]@{

 LegoSet = $Set
 Description = $Description
 DownloadLink = $PDFLink.href
 Output = $Output
 }
 $LegoSetObject += $Object

}
 else {
 Write-Warning &quot;No instructions for Lego Set $Set were found&quot;
 }
 }
 }

&quot;Link&quot; {

foreach ($href in $Link){

 # --- Retrieve the web page for the Lego instructions
 $url = Invoke-WebRequest $href

 # --- Pick out the set number from the link
 $href -match &quot;.*?(?&lt;Set&gt;\d+)&quot; | Out-Null
 $Set = $Matches.Set

# --- Find links that contain pdfs. There may be multiple for different print formats on newer modelss
 if ($PDFLink = $url.Links | Where-Object {$_.outerHTML -like '*pdf*'} | Select-Object -First 1){

$Description = $url.ParsedHtml.nameProp
 $Output = Join-Path -Path $DestinationFolder -Childpath ($Description + &quot;.pdf&quot;)

$Object = [pscustomobject]@{

 LegoSet = $Set
 Description = $Description
 DownloadLink = $PDFLink.href
 Output = $Output
 }
 $LegoSetObject += $Object
 }
 else {
 Write-Warning &quot;No instructions for Lego Set $Set were found&quot;
 }
 }
 }
 }
 }

end {
 # --- If no Force parameter, then filter the downloads to those that don't already exist
 if (-not ($PSBoundParameters.ContainsKey('Force'))){

$LegoSetObject = $LegoSetObject | Where-Object {-not (Test-Path $_.Output)}
 }

# ---
 $Job = Start-BitsTransfer -Source $LegoSetObject.DownloadLink -Destination $LegoSetObject.Output -Asynchronous

 Write-Verbose &quot;Checking the status of the BITS transfer download job....&quot;

while (($Job.JobState -eq &quot;Transferring&quot;) -or ($Job.JobState -eq &quot;Connecting&quot;)){

 Write-Verbose &quot;BITS Transfer job is still downloading....&quot;
 Start-Sleep 10}

switch ($Job.JobState){

&quot;Transferred&quot; {Complete-BitsTransfer -BitsJob $Job}
 &quot;Error&quot; {Write-Warning &quot;BITS transfer has failed...&quot; }
 default {Write-Warning &quot;Please investigate download for Lego Set &quot;}
 }
 Write-Verbose &quot;BITS transfer download job has completed....&quot;

Write-Output $LegoSetObject
 }
}

</pre>
<p>If you don&#8217;t know the set number or want an entire range then you can use the <strong>Get-LegoSetLink</strong> function to generate links to the pages on the <a href="http://lego.brickinstructions.com/">BrickInstructions.com</a> website for all of the Lego sets in that range. The list of possible ranges are on the left-hand side of the site.</p>
<p style="text-align: center;"><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego4.png"><img class="aligncenter  wp-image-2908" alt="Lego4" src="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego4.png" width="130" height="402" /></a></p>
<p style="text-align: center;">
<p style="text-align: left;">So to get the Harry Potter range:</p>
<pre class="brush: powershell; title: ; notranslate">

Get-LegoSetLink -Range &quot;Harry Potter&quot;

</pre>
<p style="text-align: center;"><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego3.png"><img class="aligncenter  wp-image-2905" alt="Lego3" src="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego3.png" width="658" height="268" /></a></p>
<p>The <strong>Get-LegoSetInstructions</strong> function will also take hyperlinks as input, so to get an entire range of instructions downloaded you can do this:</p>
<pre class="brush: powershell; title: ; notranslate">

Get-LegoSetLink -Range &quot;Harry Potter&quot; | Get-LegoSetInstructions -DestinationFolder &quot;C:\Lego\Instructions\Harry Potter&quot; -Verbose

</pre>
<p><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego5.png"><img class="aligncenter  wp-image-2911" alt="Lego5" src="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego5.png" width="639" height="112" /></a></p>
<p style="text-align: center;"><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego6.png"><img class="aligncenter  wp-image-2914" alt="Lego6" src="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego6.png" width="611" height="240" /></a></p>
<p style="text-align: center;">
<p style="text-align: center;"><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego7.png"><img class="aligncenter size-full wp-image-2918" alt="Lego7" src="http://www.jonathanmedd.net/wp-content/uploads/2013/04/Lego7.png" width="612" height="604" /></a></p>
<pre class="brush: powershell; title: ; notranslate">

function Get-LegoSetLink {
&lt;#
 .SYNOPSIS
 Function to retrieve Lego Set Links from supplied Lego range.

 .DESCRIPTION
 Function to retrieve Lego Set Links from supplied Lego range.

 .PARAMETER Range
 Range of Lego sets to retrieve links for

.INPUTS
 String

.OUTPUTS
 None.

.EXAMPLE
 PS&gt; Get-LegoSetLink -Range &quot;Star Wars&quot;

.NOTES
 Version: 1.0 - First draft
 Date: 18/04/2013
 Tag: lego,link
#&gt;
[CmdletBinding()]

Param (

 [parameter(Mandatory=$true,ValueFromPipeline=$true)]
 [ValidateNotNullOrEmpty()]
 [String]$Range

)

begin {

$ErrorActionPreference = 'Stop'
 Write-Debug $MyInvocation.MyCommand.Name
 $LegoLinkObject = @()
 }

process {

 # --- Retrieve the web page for the Lego instructions
 $EndUrl = (&quot;lego_&quot; + ($Range -replace &quot; &quot;, &quot;_&quot;) + &quot;.php&quot;).ToLower()
 $url = Invoke-WebRequest &quot;http://lego.brickinstructions.com/$EndUrl&quot;

# --- Find the Lego set links
 if ($LegoSets = $url.links | Where-Object {$_.href -like '*set=*'}){
 foreach ($LegoSet in $LegoSets){

$Object = [pscustomobject]@{

 Description = $LegoSet.innerHTML
 Link = &quot;http://lego.brickinstructions.com/&quot; + $LegoSet.href
 }
 $LegoLinkObject += $Object
 }

# If there are additional pages, e.g. for large ranges, cycle through each page to find all of the sets
 if ($AdditionalPages = $url.links | Where-Object {$_.href -like '*page=*'} | Where-Object {$_.innerhtml -match &quot;\d+&quot;} | Select-Object innerhtml,href -Unique){

foreach ($Page in $AdditionalPages){

$AdditionalPageURL = &quot;http://lego.brickinstructions.com&quot; + $Page.href
 $url = Invoke-WebRequest $AdditionalPageURL

$LegoSets = $url.links | Where-Object {$_.href -like '*set=*'}

foreach ($LegoSet in $LegoSets){

$Object = [pscustomobject]@{

 Description = $LegoSet.innerHTML
 Link = &quot;http://lego.brickinstructions.com/&quot; + $LegoSet.href
 }
 $LegoLinkObject += $Object
 }
 }
 }
 }
 else {

Write-Warning &quot;No sets are available for this range&quot;
 }
 }
 end {
 Write-Output $LegoLinkObject
 }

}

</pre>
<h4><strong>Accio Instructions!</strong></h4>
<p>&nbsp;</p>
<p><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/04/4736-harry-potter-minifigure.jpg"><img class="aligncenter size-full wp-image-2897" alt="4736-harry-potter-minifigure" src="http://www.jonathanmedd.net/wp-content/uploads/2013/04/4736-harry-potter-minifigure.jpg" width="421" height="601" /></a></p>
<img src="http://feeds.feedburner.com/~r/JonathanMedd/~4/Yk4Zmor26Rc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2013/04/downloading-single-or-entire-ranges-of-lego-set-instructions-with-powershell.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Start-BitsTransfer – Submitting greater than 60 asynchronous jobs generates error</title>
		<link>http://www.jonathanmedd.net/2013/04/start-bitstransfer-submitting-greater-than-60-asynchronous-jobs-generates-error.html</link>
		<comments>http://www.jonathanmedd.net/2013/04/start-bitstransfer-submitting-greater-than-60-asynchronous-jobs-generates-error.html#comments</comments>
		<pubDate>Mon, 22 Apr 2013 10:35:15 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2890</guid>
		<description><![CDATA[Start-BitsTransfer enables you to download multiple files using Windows&#8217; Background Intelligent Transfer Service , including the ability to have them processed as background jobs. I encountered an issue when submitting these jobs if the number of files where greater than 60, the 61st and onwards would fail to submit until the existing jobs had been completed [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://technet.microsoft.com/en-us/library/dd819420.aspx">Start-BitsTransfer</a> enables you to download multiple files using Windows&#8217; <a href="http://en.wikipedia.org/wiki/Background_Intelligent_Transfer_Service">Background Intelligent Transfer Service</a> , including the ability to have them processed as background jobs.</p>
<p>I encountered an issue when submitting these jobs if the number of files where greater than 60, the 61st and onwards would fail to submit until the existing jobs had been completed or cleared.</p>
<pre class="brush: powershell; title: ; notranslate">

Start-BitsTransfer : Object reference not set to an instance of an object.
At line:1 char:1
+ Start-BitsTransfer -Source &quot;http://intranet.server01.local/downlo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 + CategoryInfo : NotSpecified: (:) [Start-BitsTransfer], NullReferenceException
 + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.BackgroundIntelligentTransfer.Management.NewBitsTransferCommand

</pre>
<p>There is a better way to do this anyway since the source and destination paramaters will take multiple files, as long as you match them up in the right order. So you can create a single job with multiple files and so far I have not hit a limit, e.g.</p>
<pre class="brush: powershell; title: ; notranslate">

Start-BitsTransfer -Source $MyObject.DownloadLink -Destination $MyObject.Output -Asynchronous

</pre>
<p>I filed the original issue on Connect since it appears to be a bug and should at least produce a better error message.</p>
<p><a href="https://connect.microsoft.com/PowerShell/feedback/details/785266/start-bitstransfer-submitting-60-asynchronous-jobs-generates-error">https://connect.microsoft.com/PowerShell/feedback/details/785266/start-bitstransfer-submitting-60-asynchronous-jobs-generates-error</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/JonathanMedd/~4/o3MCBUEOAaw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2013/04/start-bitstransfer-submitting-greater-than-60-asynchronous-jobs-generates-error.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>London VMUG – April 25th 2013</title>
		<link>http://www.jonathanmedd.net/2013/04/london-vmug-april-25th-2013-2.html</link>
		<comments>http://www.jonathanmedd.net/2013/04/london-vmug-april-25th-2013-2.html#comments</comments>
		<pubDate>Tue, 16 Apr 2013 09:40:24 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[user group]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2882</guid>
		<description><![CDATA[&#160; There’s still time to register for the next London VMUG on April 25th 2013. As usual some excellent sessions are lined up – hope to see you there!]]></description>
				<content:encoded><![CDATA[<p>&#160;</p>
<p>There’s still time to <a href="http://www.vmug.com/e/in/eid=781" target="_blank">register</a> for the next London VMUG on April 25th 2013. As usual some excellent sessions are lined up – hope to see you there!</p>
<p><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/04/image1.png"><img title="image" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="image" src="http://www.jonathanmedd.net/wp-content/uploads/2013/04/image_thumb1.png" width="584" height="594" /></a></p>
<img src="http://feeds.feedburner.com/~r/JonathanMedd/~4/AWWAknG9-pk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2013/04/london-vmug-april-25th-2013-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Issue with PowerCLI: Not authenticated and session timeout</title>
		<link>http://www.jonathanmedd.net/2013/03/issue-with-powercli-not-authenticated-and-session-timeout.html</link>
		<comments>http://www.jonathanmedd.net/2013/03/issue-with-powercli-not-authenticated-and-session-timeout.html#comments</comments>
		<pubDate>Fri, 15 Mar 2013 14:45:02 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[powercli]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2870</guid>
		<description><![CDATA[A colleague of mine experienced this issue recently where after making a PowerCLI connection to a vCenter and instantly running a command such as Get-VM, he would be prompted by the error: Checking he was connected to a vCenter appeared to indicate that he was, i.e. returned a value. Seems like this may be an issue [...]]]></description>
				<content:encoded><![CDATA[<p>A colleague of mine experienced this issue recently where after making a PowerCLI connection to a vCenter and instantly running a command such as Get-VM, he would be prompted by the error:</p>
<pre class="brush: powershell; title: ; notranslate">

Get-VM. Not authenticated. Possible cause of this error is that the connection was left unused for a while and session has timed out.

</pre>
<p>Checking he was connected to a vCenter appeared to indicate that he was, i.e.</p>
<pre class="brush: powershell; title: ; notranslate">

$global:defaultVIServer

</pre>
<p>returned a value. Seems like this may be an issue with PowerCLI 5.1 <a href="http://communities.vmware.com/thread/426003?start=15&amp;tstart=0">since other similar reports indicate reverting to 4.1 does not have the issue</a>.</p>
<p>We didn&#8217;t have that option, so in this instance took the recommendation to amend the PowerCLI timeout as follows, which seemed to help in our case:</p>
<pre class="brush: powershell; title: ; notranslate">

Set-PowerCLIConfiguration -WebOperationTimeoutSeconds -1

</pre>
<img src="http://feeds.feedburner.com/~r/JonathanMedd/~4/UABGUwrJ1fc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2013/03/issue-with-powercli-not-authenticated-and-session-timeout.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Writing PowerShell Code on OS X using Sublime</title>
		<link>http://www.jonathanmedd.net/2013/03/writing-powershell-code-on-os-x-using-sublime.html</link>
		<comments>http://www.jonathanmedd.net/2013/03/writing-powershell-code-on-os-x-using-sublime.html#comments</comments>
		<pubDate>Thu, 14 Mar 2013 15:00:58 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[os x]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2853</guid>
		<description><![CDATA[The majority of my PowerShell code is written in a Windows VM where all the typical native PowerShell tools are available. However, occasionally I may want to quickly view or make small changes to some code in OS X. It&#8217;s possible via the built-in TextEdit application, but that&#8217;s kind of the equivalent of using Notepad [...]]]></description>
				<content:encoded><![CDATA[<p>The majority of my PowerShell code is written in a Windows VM where all the typical native PowerShell tools are available. However, occasionally I may want to quickly view or make small changes to some code in OS X. It&#8217;s possible via the built-in TextEdit application, but that&#8217;s kind of the equivalent of using Notepad on Windows, i.e. a pretty basic experience.</p>
<p style="text-align: center;"><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/03/TextEdit01.png"><img class="aligncenter  wp-image-2854" title="TextEdit01" src="http://www.jonathanmedd.net/wp-content/uploads/2013/03/TextEdit01.png" alt="" width="659" height="442" /></a></p>
<p>I recently read this <a href="http://www.theregister.co.uk/2013/03/11/verity_stob_text_editor/">review of Text Editors on The Register</a> and decided to check out <a href="http://www.sublimetext.com/">Sublime</a> after discovering PowerShell could be added as an additional language to support syntax highlighting.</p>
<p>First of all <a href="http://www.sublimetext.com/2">download</a> and install Sublime (available for OS X, Windows and Linux). To add PowerShell syntax highlighting:</p>
<p>1) Download the zip file from <a href="https://github.com/SublimeText/PowerShell">https://github.com/SublimeText/PowerShell</a></p>
<p>2) Unzip and move the contents to <strong>Users\<em>Username</em>\Library\Application Support\Sublime Text 2\Packages</strong></p>
<p>Note: I couldn&#8217;t track this down at first, the instructions stated to copy to the Packages folder, but not exactly where that would be. Fortunately, there is a menu item which will take you straight there:</p>
<p style="text-align: center;"><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/03/TextEdit03.png"><img class="aligncenter  wp-image-2859" title="TextEdit03" src="http://www.jonathanmedd.net/wp-content/uploads/2013/03/TextEdit03.png" alt="" width="554" height="121" /></a></p>
<p style="text-align: center;">
<p style="text-align: center;"><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/03/TextEdit2.png"><img class="aligncenter  wp-image-2856" title="TextEdit2" src="http://www.jonathanmedd.net/wp-content/uploads/2013/03/TextEdit2.png" alt="" width="684" height="382" /></a></p>
<p>3) Restart Sublime and now PowerShell v2 will be listed as an available syntax</p>
<p style="text-align: center;"><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/03/TextEdit04.png"><img class="aligncenter  wp-image-2862" title="TextEdit04" src="http://www.jonathanmedd.net/wp-content/uploads/2013/03/TextEdit04.png" alt="" width="314" height="380" /></a></p>
<p style="text-align: center;">
<p style="text-align: left;">Now you can work with PowerShell (and other) code in a nice interface</p>
<p style="text-align: center;"><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/03/TextEdit06.png"><img class="aligncenter  wp-image-2866" title="TextEdit06" src="http://www.jonathanmedd.net/wp-content/uploads/2013/03/TextEdit06.png" alt="" width="582" height="534" /></a></p>
<img src="http://feeds.feedburner.com/~r/JonathanMedd/~4/f7zyew6THh8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2013/03/writing-powershell-code-on-os-x-using-sublime.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PowerShell Quick Tip: Accessing the ProgramFiles(x86) Environment Variable</title>
		<link>http://www.jonathanmedd.net/2013/03/powershell-quick-tip-accessing-the-programfilesx86-environment-variable.html</link>
		<comments>http://www.jonathanmedd.net/2013/03/powershell-quick-tip-accessing-the-programfilesx86-environment-variable.html#comments</comments>
		<pubDate>Fri, 01 Mar 2013 14:51:38 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2841</guid>
		<description><![CDATA[Accessing environment variables in PowerShell is easy, either: to view all of them, or: to access a specific one. However, if you try that for the ProgramFiles(x86) environment variable you are greeted with the following error: &#160; There are a few ways around this: 1) 2) 3) 4) &#160;]]></description>
				<content:encoded><![CDATA[<p>Accessing environment variables in PowerShell is easy, either:</p>
<pre class="brush: powershell; title: ; notranslate">

dir env:

</pre>
<p>to view all of them, or:</p>
<pre class="brush: powershell; title: ; notranslate">

dir env:ProgramFiles

</pre>
<p>to access a specific one. However, if you try that for the ProgramFiles(x86) environment variable you are greeted with the following error:</p>
<pre class="brush: powershell; title: ; notranslate">

PS C:\&gt; dir env:ProgramFiles(x86)
x86 : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.

</pre>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://www.jonathanmedd.net/wp-content/uploads/2013/03/Prog1.png"><img class="aligncenter  wp-image-2843" title="Prog1" src="http://www.jonathanmedd.net/wp-content/uploads/2013/03/Prog1.png" alt="" width="616" height="168" /></a></p>
<p>There are a few ways around this:</p>
<p>1)</p>
<pre class="brush: powershell; title: ; notranslate">

dir env:ProgramFiles`(x86`)

</pre>
<p>2)</p>
<pre class="brush: powershell; title: ; notranslate">

dir &quot;env:ProgramFiles(x86)&quot;

</pre>
<p>3)</p>
<pre class="brush: powershell; title: ; notranslate">

${Env:ProgramFiles(x86)}

</pre>
<p>4)</p>
<pre class="brush: powershell; title: ; notranslate">

[Environment]::GetEnvironmentVariable(&quot;ProgramFiles(x86)&quot;)

</pre>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/JonathanMedd/~4/TxKHowK-Tds" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2013/03/powershell-quick-tip-accessing-the-programfilesx86-environment-variable.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
