<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Use PowerShell Hash Tables with Your Cmdlets</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/07/use-powershell-hash-tables-with-your-cmdlets.aspx</link><description>Summary : Learn how to Use Windows PowerShell hash tables with your cmdlets to create powerful commands.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Use PowerShell Hash Tables with Your Cmdlets</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/07/use-powershell-hash-tables-with-your-cmdlets.aspx#3440345</link><pubDate>Fri, 08 Jul 2011 11:41:46 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3440345</guid><dc:creator>shiv_09</dc:creator><description>&lt;p&gt;hullo Ed, i am trying to wrap my head around the concept of HashTables and their use. to me, a VERY novice PowerShell guy and very little scripting experience, it LOOKS like an array. &amp;nbsp;but an array you have to populate yourself to use for something else. &amp;nbsp;now i&amp;#39;ve seen where you&amp;#39;ve piped get-Process or services or whatever into the HashTable and that seems like it is a more functional use of it. but once again, it just looks like a multi-dimensional array. to me, it sounds like it could be a good idea and i know people use them but HashTables still seem confusing even after your 4-parter, which i thought was enlightening.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3440345" width="1" height="1"&gt;</description></item><item><title>re: Use PowerShell Hash Tables with Your Cmdlets</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/07/use-powershell-hash-tables-with-your-cmdlets.aspx#3440063</link><pubDate>Thu, 07 Jul 2011 11:07:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3440063</guid><dc:creator>IamMred</dc:creator><description>&lt;p&gt;@Srikanth I am sorry you got a bit confused. The key has to be unique. The values associated with the key are not unique. The thing that is a bit confusing is that the values associated with the keys are in fact collections (as @Klaus points out). &lt;/p&gt;
&lt;p&gt;I am glad you are enjoying the articles. &lt;/p&gt;
&lt;p&gt;@Klaus Schulte You are correct, I did truncate the command as well as the output (sorry about that). I have edited the post to make the section a bit clearer, and to include the missing command. To make it easy to spot, the missing command was in fact $a.values &lt;/p&gt;
&lt;p&gt;@Ryan Shafer you are also right it is a bit confusing. In addition, you are right about the missing command ... &lt;/p&gt;
&lt;p&gt;NOW, how can both @Klaus and @Ryan be right? I changed the article a bit to include both commands. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3440063" width="1" height="1"&gt;</description></item><item><title>re: Use PowerShell Hash Tables with Your Cmdlets</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/07/use-powershell-hash-tables-with-your-cmdlets.aspx#3440048</link><pubDate>Thu, 07 Jul 2011 08:53:50 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3440048</guid><dc:creator>Srikanth</dc:creator><description>&lt;p&gt;After running through a few examples on my own, I now see what is happening. The key is indeed unique, the value is a collection.&lt;/p&gt;
&lt;p&gt;Thanks, Klaus, for pointing out the same as well :-)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3440048" width="1" height="1"&gt;</description></item><item><title>re: Use PowerShell Hash Tables with Your Cmdlets</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/07/use-powershell-hash-tables-with-your-cmdlets.aspx#3440041</link><pubDate>Thu, 07 Jul 2011 08:18:33 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3440041</guid><dc:creator>Ryan Shafer</dc:creator><description>&lt;p&gt;Thanks for the great article as always Ed, &lt;/p&gt;
&lt;p&gt;I do agree with Srikanth and Klaus&amp;#39;s comments tough. &amp;nbsp; &lt;/p&gt;
&lt;p&gt;I was confused by the three matching keys as I thought they had to be unique. &amp;nbsp;When I tried to write an existing key even though the value was different I received.&lt;/p&gt;
&lt;p&gt;&amp;quot;Exception calling &amp;quot;Add&amp;quot; with &amp;quot;2&amp;quot; argument(s): &amp;quot;Item has already been added. Key in dictionary:&amp;quot;&lt;/p&gt;
&lt;p&gt;Also I noticed what Klaus mentioned where the command to produce the second set of output was omitted. &amp;nbsp;However Klaus the command was simply $a not $a.values as this would have merely displayed the values and not the pairs.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Ryan &amp;nbsp;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3440041" width="1" height="1"&gt;</description></item><item><title>re: Use PowerShell Hash Tables with Your Cmdlets</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/07/use-powershell-hash-tables-with-your-cmdlets.aspx#3440028</link><pubDate>Thu, 07 Jul 2011 08:03:06 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3440028</guid><dc:creator>Klaus Schulte</dc:creator><description>&lt;p&gt;@Srikanth: You are still thinking the right thing :-)&lt;/p&gt;
&lt;p&gt;The data structure returned from &amp;quot;group-object&amp;quot; is a little bit more complicated!&lt;/p&gt;
&lt;p&gt;It is nested and the resulting Hashtable uses the filename as unique key, right!!&lt;/p&gt;
&lt;p&gt;But the values of this hashtable are collections again:&lt;/p&gt;
&lt;p&gt;PS C:\Users\Schulte&amp;gt; $a[&amp;quot;testfile10&amp;quot;].gettype() | ft -auto&lt;/p&gt;
&lt;p&gt;IsPublic IsSerial Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BaseType &amp;nbsp; &amp;nbsp; &lt;/p&gt;
&lt;p&gt;-------- -------- ---- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -------- &amp;nbsp; &amp;nbsp; &lt;/p&gt;
&lt;p&gt;True &amp;nbsp; &amp;nbsp; True &amp;nbsp; &amp;nbsp; Collection`1 System.Object&lt;/p&gt;
&lt;p&gt;Each single value is of type Collection`1 and has a repeated property value for &amp;quot;Name&amp;quot; that corresponds to the key of the Hashtable returned by &amp;quot;group-object&amp;quot;&lt;/p&gt;
&lt;p&gt;PS C:\Users\Schulte&amp;gt; $a[&amp;quot;testfile10&amp;quot;] | ft -auto&lt;/p&gt;
&lt;p&gt;Name &amp;nbsp; &amp;nbsp; &amp;nbsp; FullName &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;---- &amp;nbsp; &amp;nbsp; &amp;nbsp; -------- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;testfile10 D:\Temp\testfiles\testfile10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;testfile10 D:\Temp\testfiles\folder1\testfile10&lt;/p&gt;
&lt;p&gt;testfile10 D:\Temp\testfiles\folder2\testfile10&lt;/p&gt;
&lt;p&gt;testfile10 D:\Temp\testfiles\folder3\testfile10&lt;/p&gt;
&lt;p&gt;So now you have four members of the collection with identical names and distinct Fullname properties! As members of a collection don&amp;#39;t need to be unique, this may solve the confusion .... ( or I made it even bigger now :-))&lt;/p&gt;
&lt;p&gt;Klaus&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3440028" width="1" height="1"&gt;</description></item><item><title>re: Use PowerShell Hash Tables with Your Cmdlets</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/07/use-powershell-hash-tables-with-your-cmdlets.aspx#3439999</link><pubDate>Thu, 07 Jul 2011 07:26:40 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3439999</guid><dc:creator>Klaus Schulte</dc:creator><description>&lt;p&gt;Very good article, Ed!&lt;/p&gt;
&lt;p&gt;I supose, you could even dive deeper and deeper into the fantastic world of hashtables! There is plenty of stuff left to experiment with for us now! Nesting objects and retrieveing particular properties or methods of them is really sometimes a bit of an art and surely needs some experience and maybe try-and-error ...&lt;/p&gt;
&lt;p&gt;One little thing, I stumbled upon reading your article:&lt;/p&gt;
&lt;p&gt;You shortened the comandline listing a little bit too much :-(&lt;/p&gt;
&lt;p&gt;look at: &lt;/p&gt;
&lt;p&gt;&amp;quot;PS C:\hsgTest&amp;gt; $a.Keys&amp;quot;&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;After: &amp;quot;&amp;lt;output is truncated to save space&amp;gt;&amp;quot; you truncated the next line, too :-)&lt;/p&gt;
&lt;p&gt;A command that produces the next, shortened output is missing.&lt;/p&gt;
&lt;p&gt;It might be a line like that:&lt;/p&gt;
&lt;p&gt;&amp;quot;C:\hsgTest&amp;gt; $a.Values&amp;quot; ???&lt;/p&gt;
&lt;p&gt;Klaus&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3439999" width="1" height="1"&gt;</description></item><item><title>re: Use PowerShell Hash Tables with Your Cmdlets</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/07/use-powershell-hash-tables-with-your-cmdlets.aspx#3439992</link><pubDate>Thu, 07 Jul 2011 07:19:10 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3439992</guid><dc:creator>Srikanth</dc:creator><description>&lt;p&gt;Ed, a bit confused here. In the 1st blog post, you mentioned that the key has to be unique, but here, we have a key that corresponds to multiple fullnames. &lt;/p&gt;
&lt;p&gt;By the way, these blog posts have been great, thanks a lot.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3439992" width="1" height="1"&gt;</description></item></channel></rss>