<?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>Hey, Scripting Guy! Blog</title><link>http://blogs.technet.com/b/heyscriptingguy/</link><description>The Hey, Scripting Guy! Blog is the number one blog hosting daily Windows PowerShell articles in a simple, scenario driven, how to format.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>PowerTip: Use PowerShell to Put Virtual Machine in Saved State</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/24/powertip-use-powershell-to-put-virtual-machine-in-saved-state.aspx</link><pubDate>Fri, 24 May 2013 18:59:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3572646</guid><dc:creator>The Scripting Guys</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/heyscriptingguy/rsscomments.aspx?WeblogPostID=3572646</wfw:commentRss><comments>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/24/powertip-use-powershell-to-put-virtual-machine-in-saved-state.aspx#comments</comments><description>&lt;p&gt;&lt;strong style="font-size: 12px;"&gt;Summary&lt;/strong&gt;&lt;span style="font-size: 12px;"&gt;: Use Windows PowerShell to put a virtual machine into a saved state.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/q-sm.jpg" alt="Hey, Scripting Guy! Question" /&gt;&amp;nbsp;How do I put a virtual machine into a saved state?&lt;/p&gt;
&lt;p style="padding-left: 60px;"&gt;&lt;img src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/a-sm.jpg" alt="Hey, Scripting Guy! Answer" /&gt;&amp;nbsp;Use the&amp;nbsp;&lt;strong&gt;Save-VM&lt;/strong&gt;&amp;nbsp;cmdlet with the name of the virtual machine in Hyper-V:&lt;/p&gt;
&lt;p style="padding-left: 150px;"&gt;Save-VM 'Contoso-FPS'&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;Or you can place all virtual machines on a Hyper-V server into saved state by using:&lt;/p&gt;
&lt;p style="padding-left: 150px;"&gt;Get-VM | Save-VM&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7610.Dr.ScriptoForTips.jpg"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/150x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7610.Dr.ScriptoForTips.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3572646" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Windows+PowerShell/">Windows PowerShell</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Scripting+Guy_2100_/">Scripting Guy!</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/guest+blogger/">guest blogger</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Sean+Kearney/">Sean Kearney</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/PowerTip/">PowerTip</category></item><item><title>Export Multiple Virtual Machines with Windows PowerShell</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/24/export-multiple-virtual-machines-with-windows-powershell.aspx</link><pubDate>Fri, 24 May 2013 07:01:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3572649</guid><dc:creator>The Scripting Guys</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/heyscriptingguy/rsscomments.aspx?WeblogPostID=3572649</wfw:commentRss><comments>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/24/export-multiple-virtual-machines-with-windows-powershell.aspx#comments</comments><description>&lt;p&gt;&lt;strong style="font-size: 12px;"&gt;Summary&lt;/strong&gt;&lt;span style="font-size: 12px;"&gt;: Microsoft PowerShell MVP, Sean Kearney, shows how to easily use Windows PowerShell in Windows Server 2012 to export multiple virtual machines.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy, Ed Wilson, is here. If you are a seasoned Hey, Scripting Guy! Blog reader, you know that the most frequent guest blogger is Sean Kearney. If you are new to the blog, I welcome you, and I encourage you to catch up with &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/sean+kearney/" target="_blank"&gt;Sean&amp;rsquo;s previous blogs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Sean is a Windows PowerShell MVP and &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/09/01/honorary-scripting-guy-award-recipients-announced.aspx" target="_blank"&gt;an Honorary Scripting Guy.&lt;/a&gt; Sean has been selected to present sessions called &lt;a href="http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/MDC-B326#fbid=rHDRO4Syj3v" target="_blank"&gt;Integrating with Microsoft System Center 2012 and Windows PowerShell&lt;/a&gt; at TechEd NA and TechEd Europe this year. In his free time, Sean has written several blog posts about Hyper-V and some other cool stuff, and for the next few weeks, Sean will be the designated guest blogger on Fridays. Take it away Sean&amp;hellip;&lt;/p&gt;
&lt;p&gt;Microsoft TechEd is fast approaching. I&amp;rsquo;m doing work on a presentation, and I decided that I want a quick way for myself and others to easily export a Hyper-V environment.&lt;/p&gt;
&lt;p&gt;Sure, you can just jump to the GUI, right-click &lt;strong&gt;Export&amp;hellip;&lt;/strong&gt;, and pick a spot.&lt;/p&gt;
&lt;p&gt;I prefer consistency. I like to say, &amp;ldquo;Here&amp;rsquo;s my virtual machines; please export them.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;To make things more specific, I have created a new virtual network called &amp;ldquo;MSTechEd.&amp;rdquo; To make things easier, I have taken my Hyper-V machines that are configured for the conference and attached them to this virtual network by using the following commands:&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;GET-VM &amp;lsquo;EOT-DC1&amp;rsquo; | GET-VMNetworkAdapter | Connect-VMNetworkAdapter &amp;ndash;Switchname &amp;lsquo;MSTechEd&amp;rsquo;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;GET-VM &amp;lsquo;EOT-SCORCH&amp;rsquo; | GET-VMNetworkAdapter | Connect-VMNetworkAdapter &amp;ndash;Switchname &amp;lsquo;MSTechEd&amp;rsquo;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;GET-VM &amp;lsquo;EOT-SCSM&amp;rsquo; | GET-VMNetworkAdapter | Connect-VMNetworkAdapter &amp;ndash;Switchname &amp;lsquo;MSTechEd&amp;rsquo;&lt;/p&gt;
&lt;p&gt;Now with a common configuration in place, I could simply pull up all my virtual machines based on the network switch name. As I added to my virtual environment, I could simply connect to this network switch, which would provide my consistency.&lt;/p&gt;
&lt;p&gt;Now all of my machines for TechEd could be accessed by using this command:&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;GET-VM | GET-VMNetworkAdapter | where { $_.SwitchName &amp;ndash;eq &amp;lsquo;MSTechEd&amp;rsquo; }&lt;/p&gt;
&lt;p&gt;Oddly, there is a parameter in the &lt;strong&gt;Get-VMNetworkAdapter&lt;/strong&gt; cmdlet called &lt;strong&gt;SwitchName&lt;/strong&gt;, but it is not designed to be used as a filter when piping in data.&lt;/p&gt;
&lt;p&gt;So now with an easy way to find specific virtual machines that match my configuration for TechEd, I can run a simple line to export the machines each and every time.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Wait a minute! How do you find out how to use the cmdlet?&amp;rdquo; (I can hear many of you shouting up and down the Internet right now.)&lt;/p&gt;
&lt;p&gt;So really...&lt;/p&gt;
&lt;p&gt;I ran &lt;strong&gt;Get-Help&lt;/strong&gt; on &lt;strong&gt;Export-VM&lt;/strong&gt; asking for examples. That&amp;rsquo;s how I learn to use cmdlets every time.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;GET-HELP EXPORT-VM &amp;ndash;Examples&lt;/p&gt;
&lt;p&gt;And here is the output:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7484.hsg_2D00_5_2D00_24_2D00_13_2D00_1.png"&gt;&lt;img title="Image of command output" src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7484.hsg_2D00_5_2D00_24_2D00_13_2D00_1.png" alt="Image of command output" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So from Example 2, I should be able to simply add the following command to my first line (where in my case, drive E: is my external USB drive for holding my virtual machines).&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;GET-VM | GET-VMNetworkAdapter | where { $_.SwitchName &amp;ndash;eq &amp;lsquo;MSTechEd&amp;rsquo; } | EXPORT-VM &amp;ndash;path E:\&lt;/p&gt;
&lt;p&gt;Now I can get back to working on my presentation, confident that I have an easy and consistent way to export my virtual machines from Hyper-V.&lt;/p&gt;
&lt;p&gt;Feel the Power within you.&lt;/p&gt;
&lt;p&gt;~Sean&lt;br /&gt; The Energized Tech&lt;/p&gt;
&lt;p&gt;Thanks once again, Sean! Join me tomorrow for the Weekend Scripter.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook" target="_blank"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ed Wilson, Microsoft Scripting Guy&lt;/strong&gt;&lt;span style="font-size: 12px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3572649" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Windows+PowerShell/">Windows PowerShell</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Scripting+Guy_2100_/">Scripting Guy!</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/guest+blogger/">guest blogger</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Sean+Kearney/">Sean Kearney</category></item><item><title>Scripting Wife Comments on Beginner Event 5</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/23/scripting-wife-comments-on-beginner-event-5.aspx</link><pubDate>Thu, 23 May 2013 18:59:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3572634</guid><dc:creator>The Scripting Guys</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/heyscriptingguy/rsscomments.aspx?WeblogPostID=3572634</wfw:commentRss><comments>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/23/scripting-wife-comments-on-beginner-event-5.aspx#comments</comments><description>&lt;p&gt;&lt;strong style="font-size: 12px;"&gt;Summary&lt;/strong&gt;&lt;span style="font-size: 12px;"&gt;: The Scripting Wife reveals her impressions of 2013 Scripting Games Beginner Event 5.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This event was tough&amp;mdash;at least for me. You see, the thing is that I can read text files, and I can get listings of text files. And these log files are just text, after all. The trouble is the part about finding IP addresses. That had me stumped. I tried using the filter with&amp;nbsp;&lt;strong&gt;Get-Content&lt;/strong&gt;, but I could not make it work for me. So in the end, I had to ask the Scripting Guy for help.&lt;/p&gt;
&lt;p&gt;Lots of luck there. But what he told me was just enough to get me moving in the right direction. He said I need to use a regular expression to find the IP address in the log files. He told me to search the Hey, Scripting Guy! Blog for&amp;nbsp;&lt;a href="http://social.technet.microsoft.com/Search/en-US?query=regex%20ip%20address&amp;amp;beta=0&amp;amp;rn=Hey%2c+Scripting+Guy!+Blog&amp;amp;rq=site:blogs.technet.com/b/heyscriptingguy/&amp;amp;ac=5" target="_blank"&gt;regular expression and IP address&lt;/a&gt;. So I did.&lt;/p&gt;
&lt;p&gt;I did not find exactly what I needed; but then again, I guess I did. What I was looking for was a Regex pattern that defines an IP address. I actually found the pattern in an old Scripting Guy blog post from 2007&amp;mdash;written in VBScript script. It does not matter, because it is the pattern I needed. Once I had the pattern, I needed to find a cmdlet that would accept a pattern, so I used&amp;nbsp;&lt;strong&gt;Get-Command&lt;/strong&gt;&amp;nbsp;like this:&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Get-Command -ParameterName pattern&lt;/p&gt;
&lt;p&gt;Then I needed to look up Help about the cmdlet I found, and figure out how to give it the Regex pattern. When I did that, I got my matches, and then I reduced the matches to unique ones. That did it. Hope this helps you. It is actually pretty cool, and it can be done as a one-liner.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3572634" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Windows+PowerShell/">Windows PowerShell</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Scripting+Guy_2100_/">Scripting Guy!</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Beginner/">Beginner</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Scripting+Wife/">Scripting Wife</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Event+5/">Event 5</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/2013+Scripting+Games/">2013 Scripting Games</category></item><item><title>2013 Scripting Games: Advanced Event 5</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/23/2013-scripting-games-advanced-event-5.aspx</link><pubDate>Thu, 23 May 2013 07:03:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3572638</guid><dc:creator>The Scripting Guys</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/heyscriptingguy/rsscomments.aspx?WeblogPostID=3572638</wfw:commentRss><comments>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/23/2013-scripting-games-advanced-event-5.aspx#comments</comments><description>&lt;p&gt;&lt;span style="font-size: 12px;"&gt;&lt;strong&gt;Summary&lt;/strong&gt;: Scripting Games Advanced Event 5:&amp;nbsp;Dr. Scripto needs to create a tool to find client IP addresses from a bunch of IIS logs.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy, Ed Wilson, is here. Today is the release of Event 5 for the 2013 Scripting Games. Remember that they are being run and hosted at &lt;a href="http://www.powershell.org/" target="_blank"&gt;www.powershell.org&lt;/a&gt;. You will need to go to that webpage to submit your entry.&lt;/p&gt;
&lt;h2&gt;The Logfile Labyrinth&lt;/h2&gt;
&lt;p&gt;Dr. Scripto finds himself in possession of a bunch of IIS log files. (It is much like the one at &lt;a href="http://morelunches.com/files/powershell3/LogFiles.zip" target="_blank"&gt;http://morelunches.com/files/powershell3/LogFiles.zip&lt;/a&gt;, if you need one to practice with.) He&amp;rsquo;s keeping all of the log files in C:\Reporting\LogFiles, and he&amp;rsquo;s left the log files with their default file names, which he&amp;rsquo;s given a .log file name extension. All of the files are for a single website, on a single web server.&lt;/p&gt;
&lt;p&gt;He&amp;rsquo;d like you to write a tool that accepts a path, and then simply scans through each file in that path, generating a list of each unique client IP address that have been used to access the website. No IP address should appear more than once in your output, and you don&amp;rsquo;t need to sort the output in any way.&lt;/p&gt;
&lt;p&gt;Your tool should optionally accept an IP address mask, such as &amp;ldquo;192.0.1.*&amp;rdquo; and only display IP addresses that match the specified pattern. If run without a pattern, display all IP addresses.&lt;/p&gt;
&lt;p&gt;As described in &lt;a href="http://technet.microsoft.com/en-us/library/cc781851%28v=ws.10%29.aspx" target="_blank"&gt;IIS Log File Example&lt;/a&gt;, the client IP address is the first item in each log file entry. Regardless of the addresses found in the sample file, you should assume that any legal IP address may appear in the files Dr. Scripto needs to scan. Your command should scan &lt;em&gt;all&lt;/em&gt; of the files in the folder (and the folder doesn&amp;rsquo;t contain any other kind of file) and produce a single set of results. If an IP address appears in multiple log files (it&amp;rsquo;s likely that will be the case), your final output should still only list that IP address one time.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 12px;"&gt;I invite you to follow me on &lt;/span&gt;&lt;a style="font-size: 12px;" href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt;&lt;span style="font-size: 12px;"&gt; and &lt;/span&gt;&lt;a href="http://bit.ly/scriptingguysfacebook" target="_blank"&gt;Facebook&lt;/a&gt;&lt;span style="font-size: 12px;"&gt;. If you have any questions, send email to me at &lt;/span&gt;&lt;a style="font-size: 12px;" href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;&lt;span style="font-size: 12px;"&gt;, or post your questions on the &lt;/span&gt;&lt;a style="font-size: 12px;" href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;&lt;span style="font-size: 12px;"&gt;. See you tomorrow. Until then, peace.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ed Wilson, Microsoft Scripting Guy&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3572638" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Windows+PowerShell/">Windows PowerShell</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Scripting+Guy_2100_/">Scripting Guy!</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Advanced/">Advanced</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Event+5/">Event 5</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/2013+Scripting+Games/">2013 Scripting Games</category></item><item><title>2013 Scripting Games: Beginner Event 5</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/23/2013-scripting-games-beginner-event-5.aspx</link><pubDate>Thu, 23 May 2013 07:01:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3572636</guid><dc:creator>The Scripting Guys</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/heyscriptingguy/rsscomments.aspx?WeblogPostID=3572636</wfw:commentRss><comments>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/23/2013-scripting-games-beginner-event-5.aspx#comments</comments><description>&lt;p&gt;&lt;strong style="font-size: 12px;"&gt;Summary&lt;/strong&gt;&lt;span style="font-size: 12px;"&gt;: Scripting Games Beginner Event 5:&amp;nbsp;Dr. Scripto needs to find client IP addresses from IIS logs.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy, Ed Wilson, is here. Today is the release of Event 5 for the 2013 Scripting Games. Remember that they are being run and hosted at&amp;nbsp;&lt;a href="http://www.powershell.org/"&gt;www.powershell.org&lt;/a&gt;. You will need to go to that webpage to submit your entry.&lt;/p&gt;
&lt;h2&gt;The Logfile Labyrinth&lt;/h2&gt;
&lt;p&gt;Dr. Scripto finds himself in possession of a bunch of IIS log files. (It is much like the one at&amp;nbsp;&lt;a href="http://morelunches.com/files/powershell3/LogFiles.zip" target="_blank"&gt;http://morelunches.com/files/powershell3/LogFiles.zip&lt;/a&gt;, if you need one to practice with.) He&amp;rsquo;s keeping all of the log files in C:\Reporting\LogFiles, and he&amp;rsquo;s left the log files with their default file names, which he&amp;rsquo;s given a .log file name extension. All of the files are for a single website, on a single web server.&lt;/p&gt;
&lt;p&gt;He&amp;rsquo;d like you to simply scan through each file, and generate a list of each unique client IP address that&amp;rsquo;s been used to access the website. No IP address should appear more than once in your output, and you don&amp;rsquo;t need to sort the output in any way.&lt;/p&gt;
&lt;p&gt;As described in&amp;nbsp;&lt;a href="http://technet.microsoft.com/en-us/library/cc781851%28v=ws.10%29.aspx" target="_blank"&gt;IIS Log File Example&lt;/a&gt;, the client IP address is the first item in each log file entry. Regardless of the addresses found in the sample file, you should assume that any legal IP address may appear in the files that Dr. Scripto needs to scan. Your command should scan&amp;nbsp;&lt;em&gt;all&lt;/em&gt;&amp;nbsp;of the files in the folder (and the folder doesn&amp;rsquo;t contain any other kind of file) and produce a single set of results. If an IP address appears in multiple log files (it&amp;rsquo;s likely that will be the case), your final output should still only list that IP address one time.&lt;/p&gt;
&lt;p&gt;Dr. Scripto is getting a little tired, so he&amp;rsquo;s asked you to keep your command as short and concise as possible, although you&amp;rsquo;re welcome to use full command names and full parameter names to make things easy to read.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on&amp;nbsp;&lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="http://bit.ly/scriptingguysfacebook" target="_blank"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at&amp;nbsp;&lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the&amp;nbsp;&lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ed Wilson, Microsoft Scripting Guy&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3572636" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Windows+PowerShell/">Windows PowerShell</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Scripting+Guy_2100_/">Scripting Guy!</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Beginner/">Beginner</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Event+5/">Event 5</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/2013+Scripting+Games/">2013 Scripting Games</category></item><item><title>PowerTip: Find Format Data Used by Current PowerShell Session</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/22/powertip-find-format-data-used-by-current-powershell-session.aspx</link><pubDate>Wed, 22 May 2013 18:59:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3572437</guid><dc:creator>The Scripting Guys</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/heyscriptingguy/rsscomments.aspx?WeblogPostID=3572437</wfw:commentRss><comments>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/22/powertip-find-format-data-used-by-current-powershell-session.aspx#comments</comments><description>&lt;p&gt;&lt;strong style="font-size: 12px;"&gt;Summary&lt;/strong&gt;&lt;span style="font-size: 12px;"&gt;: Find the Windows PowerShell format data files that are used in your current Windows PowerShell session.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/q-sm.jpg" alt="Hey, Scripting Guy! Question" /&gt;&amp;nbsp;How can I find the format data files that are being used in my current Windows PowerShell&amp;nbsp;session?&lt;/p&gt;
&lt;p style="padding-left: 60px;"&gt;&lt;img src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/a-sm.jpg" alt="Hey, Scripting Guy! Answer" /&gt;&amp;nbsp;Use the&amp;nbsp;&lt;strong&gt;Get-FormatData&lt;/strong&gt;&amp;nbsp;cmdlet in Windows PowerShell&amp;nbsp;3.0, and to browse this information, pipe the results to the&amp;nbsp;&lt;strong&gt;More&lt;/strong&gt;&amp;nbsp;command:&lt;/p&gt;
&lt;p style="padding-left: 150px;"&gt;Get-FormatData | more&lt;span style="font-size: 12px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7610.Dr.ScriptoForTips.jpg"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/150x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7610.Dr.ScriptoForTips.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3572437" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Windows+PowerShell/">Windows PowerShell</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Scripting+Guy_2100_/">Scripting Guy!</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/PowerTip/">PowerTip</category></item><item><title>Variable Substitution in a PowerShell Script Block</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/22/variable-substitution-in-a-powershell-script-block.aspx</link><pubDate>Wed, 22 May 2013 07:01:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3572439</guid><dc:creator>The Scripting Guys</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/heyscriptingguy/rsscomments.aspx?WeblogPostID=3572439</wfw:commentRss><comments>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/22/variable-substitution-in-a-powershell-script-block.aspx#comments</comments><description>&lt;p&gt;&lt;strong style="font-size: 12px;"&gt;Summary&lt;/strong&gt;&lt;span style="font-size: 12px;"&gt;: Microsoft Scripting Guy, Ed Wilson, talks about performing variable substitution inside a Windows PowerShell script block.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/q-sm.jpg" alt="Hey, Scripting Guy! Question" /&gt;&amp;nbsp;Hey, Scripting Guy! &amp;nbsp;I am trying to create a command. The command contains variables that I would like to assign prior to creating the command. However, when I get to the script block portion of my code, it does not do the variable substitution for the value the way an expanding string normally works. Can you help me?&lt;/p&gt;
&lt;p&gt;&amp;mdash;SW&lt;/p&gt;
&lt;p&gt;&lt;img src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/a-sm.jpg" alt="Hey, Scripting Guy! Answer" /&gt;&amp;nbsp;Hello SW,&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy, Ed Wilson, is here. Last week at the first ever Northern Virginia PowerShell User Group, the Scripting Wife and I found a great little tea shop. I can&amp;rsquo;t help but thinking about the scone I got there&amp;mdash;it was pretty good.&lt;/p&gt;
&lt;h2&gt;Expanding variable values&lt;/h2&gt;
&lt;p&gt;One of the really cool things about Windows PowerShell is the expanding strings&amp;mdash;I absolutely love them. It surely beats having to do lots of string concatenation like I had to do back in the VBScript days. To illustrate this technique, I assign a string to the value of a variable&amp;mdash;in this case, the &lt;strong&gt;$a&lt;/strong&gt; variable. I look at the value contained in the variable. This code is shown here.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $a = "This is a string"&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $a&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;This is a string&lt;/p&gt;
&lt;p&gt;Now, by using the expanding string, I can see the value that is contained inside the &lt;strong&gt;$a&lt;/strong&gt; variable. To suppress the variable expansion, I escape it with the grave accent character as shown here.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; "The value of `$a is $a"&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;The value of $a is This is a string&lt;/p&gt;
&lt;h2&gt;The problem with a script block&lt;/h2&gt;
&lt;p&gt;If, on the other hand, I want to expand the value of a variable inside a script block, it does not work. This is shown in the code that follows.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $a = "This is a string"&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $a&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;This is a string&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $b = {"The value of `$a is $a"}&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $b&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;"The value of `$a is $a"&lt;/p&gt;
&lt;h2&gt;Solving the problem with variable expansion in a script block&lt;/h2&gt;
&lt;p&gt;The solution to expanding a variable inside a script block is to do two things. First create the script block as an expanding string. This is shown here:&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $a = "This is a string"&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $a&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;This is a string&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $b = "The value of `$a is $a"&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $b&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;The value of $a is This is a string&lt;/p&gt;
&lt;p&gt;Now, I use the static &lt;strong&gt;Create&lt;/strong&gt;&lt;em&gt; &lt;/em&gt;method from the &lt;strong&gt;[scriptblock]&lt;/strong&gt; class. This will create a script block. To do this, I use the &lt;strong&gt;[scriptblock]&lt;/strong&gt; class and then call the &lt;strong&gt;Create&lt;/strong&gt;&lt;em&gt; &lt;/em&gt;method while passing the string contained in the &lt;strong&gt;$b&lt;/strong&gt; variable. This is shown here.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; [scriptblock]::Create($b)&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;The value of $a is This is a string&lt;/p&gt;
&lt;p&gt;I can confirm that it is in fact a script block by piping the results to the &lt;strong&gt;Get-Member&lt;/strong&gt; cmdlet as shown here:&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; [scriptblock]::Create($b) | gm&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; TypeName: System.Management.Automation.ScriptBlock&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Name&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;&amp;nbsp;&amp;nbsp; MemberType Definition&lt;/p&gt;
&lt;p style="padding-left: 30px;"&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;&amp;nbsp;&amp;nbsp; ---------- ----------&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;CheckRestrictedLanguage Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void CheckRestrictedLanguage(System.Collection...&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Equals&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; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool Equals(System.Object obj)&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;GetHashCode&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int GetHashCode()&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;GetNewClosure&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; scriptblock GetNewClosure()&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;GetObjectData&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void GetObjectData(System.Runtime.Serializatio...&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;GetPowerShell&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; powershell GetPowerShell(Params System.Object[...&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;GetSteppablePipeline&amp;nbsp;&amp;nbsp;&amp;nbsp; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Management.Automation.SteppablePipeline...&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;GetType&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; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type GetType()&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Invoke&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; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Collections.ObjectModel.Collection[psob...&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;InvokeReturnAsIs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Object InvokeReturnAsIs(Params System.O...&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;ToString&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; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string ToString()&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Ast&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; Property&amp;nbsp;&amp;nbsp; System.Management.Automation.Language.Ast Ast ...&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Attributes&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; Property&amp;nbsp;&amp;nbsp; System.Collections.Generic.List[System.Attribu...&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;File&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;&amp;nbsp;&amp;nbsp; Property&amp;nbsp;&amp;nbsp; string File {get;}&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;IsFilter&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; Property&amp;nbsp;&amp;nbsp; bool IsFilter {get;set;}&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Module&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; Property&amp;nbsp;&amp;nbsp; psmoduleinfo Module {get;}&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;StartPosition&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Property&amp;nbsp;&amp;nbsp; System.Management.Automation.PSToken StartPosi...&lt;/p&gt;
&lt;p&gt;Now, the cool thing about this is that I can also store the script block into another variable. This is shown here:&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;$sb = [scriptblock]::Create($b)&lt;/p&gt;
&lt;p&gt;After I have stored the script block into the variable, I can also call any of the methods or properties of the script block. For example, here is the AST:&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $sb.Ast&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;ParamBlock&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;BeginBlock&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;ProcessBlock&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;EndBlock&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : The value of $a is This is a string&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;DynamicParamBlock&amp;nbsp; :&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;ScriptRequirements :&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Extent&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : The value of $a is This is a string&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Parent&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;&lt;span style="font-size: 12px;"&gt;It is not horribly exciting in this example, but for more complex code, it is definitely exciting stuff. We have a great Hey, Scripting Guy! Blog post written by Bartek Bielawski, which offers several good ideas for further exploration: &lt;/span&gt;&lt;a style="font-size: 12px;" href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/09/26/learn-how-it-pros-can-use-the-powershell-ast.aspx" target="_blank"&gt;Learn How IT Pros Can Use the PowerShell AST&lt;/a&gt;&lt;span style="font-size: 12px;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;SW, that is all there is to using variable expansion and substitution in a Windows PowerShell script block.&amp;nbsp; Join me tomorrow when I will talk about way cool Windows PowerShell stuff.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook" target="_blank"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ed Wilson, Microsoft Scripting Guy&lt;/strong&gt;&lt;span style="font-size: 12px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3572439" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Windows+PowerShell/">Windows PowerShell</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Scripting+Guy_2100_/">Scripting Guy!</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/scripting+techniques/">scripting techniques</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/getting+started/">getting started</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Strings/">Strings</category></item><item><title>PowerTip: Create a PowerShell Script Block on the Fly</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/21/powertip-create-a-powershell-script-block-on-the-fly.aspx</link><pubDate>Tue, 21 May 2013 18:59:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3572431</guid><dc:creator>The Scripting Guys</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/heyscriptingguy/rsscomments.aspx?WeblogPostID=3572431</wfw:commentRss><comments>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/21/powertip-create-a-powershell-script-block-on-the-fly.aspx#comments</comments><description>&lt;p&gt;&lt;strong style="font-size: 12px;"&gt;Summary&lt;/strong&gt;&lt;span style="font-size: 12px;"&gt;: Create a Windows PowerShell script block on the fly.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/q-sm.jpg" alt="Hey, Scripting Guy! Question" /&gt;&amp;nbsp;How can I convert a string into a Windows PowerShell script block?&lt;/p&gt;
&lt;p style="padding-left: 60px;"&gt;&lt;img src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/a-sm.jpg" alt="Hey, Scripting Guy! Answer" /&gt;&amp;nbsp;Use the static&amp;nbsp;&lt;strong&gt;Create&lt;/strong&gt;&amp;nbsp;method from the&amp;nbsp;&lt;strong&gt;[scriptblock]&lt;/strong&gt;&amp;nbsp;class:&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;PS C:\&amp;gt; [scriptblock]::Create("this is a string") | gm&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;&amp;nbsp;&amp;nbsp; TypeName: System.Management.Automation.ScriptBlock&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;Name&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;&amp;nbsp;&amp;nbsp; MemberType Definition&lt;/p&gt;
&lt;p style="padding-left: 120px;"&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;&amp;nbsp;&amp;nbsp; ---------- ----------&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;CheckRestrictedLanguage Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void CheckRestrictedLanguage(System.Collection..&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;Equals&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; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool Equals(System.Object obj)&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;GetHashCode&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int GetHashCode()&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;GetNewClosure&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; scriptblock GetNewClosure()&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;GetObjectData&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void GetObjectData(System.Runtime.Serializatio..&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;GetPowerShell&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; powershell GetPowerShell(Params System.Object[..&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;GetSteppablePipeline&amp;nbsp;&amp;nbsp;&amp;nbsp; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Management.Automation.SteppablePipeline..&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;GetType&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;Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type GetType()&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;Invoke&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; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Collections.ObjectModel.Collection[psob..&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;InvokeReturnAsIs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Object InvokeReturnAsIs(Params System.O..&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;ToString&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; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string ToString()&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;Ast&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; Property&amp;nbsp;&amp;nbsp; System.Management.Automation.Language.Ast Ast ..&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;Attributes&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; Property&amp;nbsp;&amp;nbsp; System.Collections.Generic.List[System.Attribu..&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;File&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;&amp;nbsp;&amp;nbsp; Property&amp;nbsp;&amp;nbsp; string File {get;}&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;IsFilter&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; Property&amp;nbsp;&amp;nbsp; bool IsFilter {get;set;}&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;Module&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; Property&amp;nbsp;&amp;nbsp; psmoduleinfo Module {get;}&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;StartPosition&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Property&amp;nbsp;&amp;nbsp; System.Management.Automation.PSToken StartPosi..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3572431" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Windows+PowerShell/">Windows PowerShell</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Scripting+Guy_2100_/">Scripting Guy!</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/PowerTip/">PowerTip</category></item><item><title>PowerShell Hash Tables that Contain Keywords...hmm...</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/21/powershell-hash-tables-that-contain-keywords-hmm.aspx</link><pubDate>Tue, 21 May 2013 07:01:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3572433</guid><dc:creator>The Scripting Guys</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/heyscriptingguy/rsscomments.aspx?WeblogPostID=3572433</wfw:commentRss><comments>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/21/powershell-hash-tables-that-contain-keywords-hmm.aspx#comments</comments><description>&lt;p&gt;&lt;strong style="font-size: 12px;"&gt;Summary&lt;/strong&gt;&lt;span style="font-size: 12px;"&gt;: Microsoft Scripting Guy, Ed Wilson, talks about dealing with Windows PowerShell hash tables that contain keywords. Dude!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/q-sm.jpg" alt="Hey, Scripting Guy! Question" /&gt;&amp;nbsp;Hey, Scripting Guy! I have a problem in that I want to create a hash table from an array. This is easy enough to do, but if the array contains keywords, then everything goes pear shaped. Any ideas?&lt;/p&gt;
&lt;p&gt;&amp;mdash;GP&lt;/p&gt;
&lt;p&gt;&lt;img src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/a-sm.jpg" alt="Hey, Scripting Guy! Answer" /&gt;&amp;nbsp;Hello GP,&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy, Ed Wilson, is here. Things are certainly&amp;nbsp; becoming exciting around here. The Scripting Wife and I have been busy planning for TechEd North America in New Orleans and TechEd Europe in Madrid. As it turns out, we will have a Scripting Guys booth in both New Orleans and Madrid. In addition, we are sharing our booth with the folks from PowerShell.org; so, that means that Windows PowerShell people like Don Jones will be there. I am also going to be working with the Windows PowerShell team on a couple of instructor lead labs that (to be quite honest) will absolutely knock your socks off &amp;mdash;they are that cool. More details to follow.&lt;/p&gt;
&lt;h2&gt;Creating a hash table that contains keywords&lt;/h2&gt;
&lt;p&gt;Well GP, I have never actually run across your problem before. This is because I avoid using Windows PowerShell keywords. I refer to the Help topic,&amp;nbsp;&lt;a href="http://technet.microsoft.com/en-us/library/hh847744.aspx" target="_blank"&gt;about_Language_Keywords&lt;/a&gt;, from time to time to refresh my mind when it comes to reserved keywords.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;strong&gt;Note&lt;/strong&gt; &amp;nbsp; As an aside, I do the same thing for automatic variables. For more information, see &lt;a href="http://technet.microsoft.com/en-us/library/hh847768.aspx" target="_blank"&gt;about_Automatic_Variables&lt;/a&gt; in the Script Center.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here is the easy way to bring up the about_Language_Keywords Help topic:&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;help -Category helpfile -Name *keyword*&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;So, this is all on the preventive side of things. To experiment with this, the first thing I do is create an array that contains a few keywords&amp;mdash;in addition to other words. I then use the &lt;strong&gt;ForEach&lt;/strong&gt;&lt;em&gt; &lt;/em&gt;command to add the items in the array to a hash table. This technique is shown here:&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $a = "key","keys","property","properties","red","blue","green"&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $h = @{}&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; foreach ($wd in $a) {$h[$wd] = $true}&lt;/p&gt;
&lt;p&gt;If I look at the hash table that is contained in the &lt;strong&gt;$h&lt;/strong&gt; variable, I see the following:&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $h&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Name&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Value&lt;/p&gt;
&lt;p style="padding-left: 30px;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -----&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;red&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; True&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;property&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; True&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;green&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; True&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;keys&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; True&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;properties&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; True&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;blue&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; True&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;key&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; True&lt;/p&gt;
&lt;p&gt;So far, so good.&amp;nbsp; But suppose I want to look at the properties or the keys of my hash table. I try the following:&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $h.Keys&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;True&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $h.key&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;True&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $h.property&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;True&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $h.properties&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;True&lt;/p&gt;
&lt;p&gt;So I am wondering what the properties really are for this hash table. I can find out by using the &lt;strong&gt;Get-Member&lt;/strong&gt; command as shown here.&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; Get-Member -InputObject $h -MemberType Properties&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; TypeName: System.Collections.Hashtable&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MemberType Definition&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;----&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 style="padding-left: 30px;"&gt;Count&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Property&amp;nbsp;&amp;nbsp; int Count {get;}&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;IsFixedSize&amp;nbsp;&amp;nbsp;&amp;nbsp; Property&amp;nbsp;&amp;nbsp; bool IsFixedSize {get;}&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;IsReadOnly&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Property&amp;nbsp;&amp;nbsp; bool IsReadOnly {get;}&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;IsSynchronized Property&amp;nbsp;&amp;nbsp; bool IsSynchronized {get;}&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Keys&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Property&amp;nbsp;&amp;nbsp; System.Collections.ICollection Keys {get;}&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;SyncRoot&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Property&amp;nbsp;&amp;nbsp; System.Object SyncRoot {get;}&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Values&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Property&amp;nbsp;&amp;nbsp; System.Collections.ICollection Values {get;}&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 12px;"&gt;There really is a property called &lt;/span&gt;&lt;strong style="font-size: 12px;"&gt;Keys&lt;/strong&gt;&lt;em style="font-size: 12px;"&gt;, &lt;/em&gt;&lt;span style="font-size: 12px;"&gt;and I really cannot seem to access it. So what do I do?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I imagine that I will take a look at the base Windows PowerShell object. To do this, I use the &lt;strong&gt;PSBase&lt;/strong&gt;&lt;em&gt; &lt;/em&gt;property. All Windows PowerShell objects have a base object, but most of the time, it is not necessary to fool with it. Here, however, I suspect that I will be able to get past the &lt;em&gt;keys keys &lt;/em&gt;kind of thing. Here is the base object:&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $h.psbase&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;IsReadOnly&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : False&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;IsFixedSize&amp;nbsp;&amp;nbsp;&amp;nbsp; : False&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;IsSynchronized : False&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Keys&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : {red, property, green, keys...}&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Values&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : {True, True, True, True...}&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;SyncRoot&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : System.Object&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;Count&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 7&lt;/p&gt;
&lt;p&gt;Now, I see there is a &lt;strong&gt;Keys&lt;/strong&gt;&lt;em&gt; &lt;/em&gt;property on the base object. So I attempt to access it. Here is how I do it:&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;PS C:\&amp;gt; $h.psbase.keys&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;red&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;property&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;green&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;keys&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;properties&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;blue&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;key&lt;/p&gt;
&lt;p&gt;GP, that is all there is to using &lt;strong&gt;PSBase&lt;/strong&gt; when dealing with hash tables. By the way, I tested this on Windows PowerShell&amp;nbsp;2.0 and on Windows PowerShell&amp;nbsp;3.0, so you should be safe to use this technique. Join me tomorrow when I will talk about more cool Windows PowerShell stuff.&lt;/p&gt;
&lt;p&gt;I invite you to follow me on &lt;a href="http://bit.ly/scriptingguystwitter" target="_blank"&gt;Twitter&lt;/a&gt; and &lt;a href="http://bit.ly/scriptingguysfacebook" target="_blank"&gt;Facebook&lt;/a&gt;. If you have any questions, send email to me at &lt;a href="mailto:scripter@microsoft.com" target="_blank"&gt;scripter@microsoft.com&lt;/a&gt;, or post your questions on the &lt;a href="http://bit.ly/scriptingforum" target="_blank"&gt;Official Scripting Guys Forum&lt;/a&gt;. See you tomorrow. Until then, peace.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ed Wilson, Microsoft Scripting Guy&lt;/strong&gt;&lt;span style="font-size: 12px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3572433" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Windows+PowerShell/">Windows PowerShell</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Scripting+Guy_2100_/">Scripting Guy!</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/scripting+techniques/">scripting techniques</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/HashTables/">HashTables</category></item><item><title>PowerTip: Create an XML Representation of a Registry Key with PowerShell</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/20/powertip-create-an-xml-representation-of-a-registry-key-with-powershell.aspx</link><pubDate>Mon, 20 May 2013 18:59:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3573409</guid><dc:creator>The Scripting Guys</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.technet.com/b/heyscriptingguy/rsscomments.aspx?WeblogPostID=3573409</wfw:commentRss><comments>http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/20/powertip-create-an-xml-representation-of-a-registry-key-with-powershell.aspx#comments</comments><description>&lt;p&gt;&lt;strong style="font-size: 12px;"&gt;Summary&lt;/strong&gt;&lt;span style="font-size: 12px;"&gt;: Use Windows PowerShell to create an XML representation of a registry key.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/q-sm.jpg" alt="Hey, Scripting Guy! Question" /&gt;&amp;nbsp;How can I easily create an XML representation of a registry key by using Windows PowerShell?&lt;/p&gt;
&lt;p style="padding-left: 60px;"&gt;&lt;img src="http://img.microsoft.com/library/media/1033/technet/images/scriptcenter/qanda/a-sm.jpg" alt="Hey, Scripting Guy! Answer" /&gt;&amp;nbsp;Use the&amp;nbsp;&lt;strong&gt;Get-ChildItem&lt;/strong&gt;&amp;nbsp;cmdllet and the registry provider to get the registry key, and pipe the results to the&amp;nbsp;&lt;strong&gt;Export-CliXML&lt;/strong&gt;&amp;nbsp;cmdlet:&lt;/p&gt;
&lt;p style="padding-left: 120px;"&gt;Get-ChildItem 'HKCU:\Software\Microsoft\Active Setup' -Recurse | Export-Clixml -Path c:\fso\active.xml&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7610.Dr.ScriptoForTips.jpg"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/150x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7610.Dr.ScriptoForTips.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3573409" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Windows+PowerShell/">Windows PowerShell</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/Scripting+Guy_2100_/">Scripting Guy!</category><category domain="http://blogs.technet.com/b/heyscriptingguy/archive/tags/PowerTip/">PowerTip</category></item></channel></rss>