<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://powershell.com/cs/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>Search results for 'app:weblogs' matching tags 'disk drives and volumes', 'Windows PowerShell', and 'storage'</title><link>http://powershell.com/cs/search/SearchResults.aspx?q=app:weblogs&amp;tag=disk+drives+and+volumes,Windows+PowerShell,storage&amp;orTags=0&amp;o=DateDescending</link><description>Search results for 'app:weblogs' matching tags 'disk drives and volumes', 'Windows PowerShell', and 'storage'</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 (Build: 30929.2835)</generator><item><title>Weekend Scripter: The Scripting Wife Talks About the First Warm-Up Event in the Winter Scripting Games</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2013/02/10/weekend-scripter-the-scripting-wife-talks-about-the-first-warm-up-event-in-the-winter-scripting-games.aspx</link><pubDate>Sun, 10 Feb 2013 06:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:21526</guid><dc:creator>Anonymous</dc:creator><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 talks about the first event in the 2013 Winter Scripting Games warm-up events.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy, Ed Wilson, is here. Today, we have a special guest. You guessed it: The Scripting Wife is with us today. If you are reading the Hey, Scripting Guy! Blog for the first time, Welcome.&lt;/p&gt;
&lt;p&gt;Let me give you a little background. My real-life wife, Teresa, is not an IT person&amp;mdash;she is an accounting kind of lady. However, over the years, she has gotten involved in the Windows PowerShell community and is a tremendous asset, if I do say so myself. Teresa thought the Scripting Games sounded like fun and joined in a couple of years ago. This turned out to be a fun way to use Teresa as an example for how you too can learn Windows PowerShell. There are several &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/scripting+wife/" target="_blank"&gt;blogs&lt;/a&gt; that we have written where Teresa has been the student, and I have conducted training scenarios with her. Now that you are up to speed I will turn the keyboard over to Teresa.&lt;/p&gt;
&lt;p&gt;Hello everyone, thank you for joining us today. I am so happy to see the Winter &lt;a href="http://powershell.org/games/" target="_blank"&gt;Scripting Games&lt;/a&gt; Camp warm-up events. &lt;a href="http://powershell.org/games/Sg2013Guide.pdf" target="_blank"&gt;The Competitor Guide&lt;/a&gt; is available from the PowerShell.Org web site. I have completed the first scenario and wanted to share with you how I solved the scenario just in case you did not have time to complete the task.&lt;/p&gt;
&lt;p&gt;The first task is now over, but the second task opened on February 8, 2013. Part of the purpose for these events is to test the new Scripting Games platform, as well as to give the PowerShell.Org community some first-hand experience in running the games. The Scripting Games (as you may know) has been turned over to the Windows PowerShell community. (&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/18/weekend-scripter-first-peek-at-the-2013-scripting-games.aspx?Redirected=true" target="_blank"&gt;See the announcement on the Scripting Guys blog&lt;/a&gt;, as well as on the &lt;a href="http://powershell.org/games/" target="_blank"&gt;PowerShell.Org website&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;The task for this first event was to display the percentage of free space (in two digits) for my disk drive.&lt;/p&gt;
&lt;p&gt;Whenever I think about doing stuff with the disk drive, I think about using WMI. My first choice is Win32_Volume.&lt;/p&gt;
&lt;p&gt;I did a search on the Hey, Scripting Guy! Blog and came up with &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/14/powertip-formatting-numeric-output-using-powershell.aspx" target="_blank"&gt;this hit&lt;/a&gt; that talked about using format specifiers to control the way that the information displays to the Windows PowerShell console. I also found a good Hey, Scripting Guy! Blog post called &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/08/use-powershell-to-create-a-report-displaying-free-disk-space.aspx" target="_blank"&gt;Use PowerShell to Create a Report Displaying Free Disk Space&lt;/a&gt;&lt;em&gt; &lt;/em&gt;that basically contains the entire solution to the problem. When I saw that, I decided to not look at it yet. I decided to go back and review a &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/03/06/learn-how-to-create-custom-column-heads-for-powershell-out-gridview.aspx" target="_blank"&gt;Scripting Wife article where I talk about creating custom table headings with Out-GridView&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;After I had spent some time reviewing the articles, and making sure that I do not cheat, I decided to take a stab at it (ok, several stabs). The first part is pretty straightforward&amp;mdash;I know I need to use &lt;strong&gt;Get-WmiObject&lt;/strong&gt; to query WMI. I know I want to use the &lt;strong&gt;Win32_Volume&lt;/strong&gt; WMI class. I also know that &lt;strong&gt;gwmi&lt;/strong&gt; is an alias for the &lt;strong&gt;Get-WmiObject&lt;/strong&gt; cmdlet, as shown here.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;gwmi win32_volume&lt;/p&gt;
&lt;p&gt;The hard part is to display the percentage of free disk space in only two decimal places. This is where the format specifiers come into play &amp;hellip; and they do not play very nicely. If I want to format a number with two decimal places, I first define the pattern. This pattern goes inside a pair of quotation marks and inside a pair of curly brackets. The other part I really do not understand&amp;mdash;I just copied it and it works.&lt;/p&gt;
&lt;p&gt;Now, I do know that I use &lt;strong&gt;&amp;ndash;f&lt;/strong&gt;, which is the format operator. This is really just one of those things I need to know how to find it, so I have a pattern to do what I need to do. I can&amp;rsquo;t memorize it very well, because I do not do it all that often&amp;mdash;but hey, as long as I can find the Scripting Guy blog and search for it, then I can find what I need.&lt;/p&gt;
&lt;p&gt;If I want to display the number 123.00345 as two decimal places, I would use the following code.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;17:37 C:\&amp;gt; &amp;quot;{0:N2}&amp;quot; -f 123.00345&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;123.00&lt;/p&gt;
&lt;p&gt;Now, for another thing that is not very straightforward, but at least it is well-documented in Help&amp;mdash;creating a custom table label and computed number. We know about the two percentage places, and now we need to divide and multiply to get the percent free space. I divide freespace by capacity, and multiply by 100. To get it into a custom table, I specify Label and Expression. The Label is a string that becomes the Column heading. The expression is the script block that figures out the free space and also formats the output in two decimal places. The event required a one-liner. The following is a single logical line I broke up for readability purposes.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;gwmi win32_volume |&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;ft DriveLetter, FreeSpace, Capacity,&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;@{Label=&amp;quot;PercentFree&amp;quot;;Expression= {&amp;quot;{0:N2}&amp;quot; -f (($_.freespace / $_.capacity) * 100)}}&lt;/p&gt;
&lt;p&gt;The one line of code and the output associated with the code are shown in the following image.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/8304.hsg_2D00_2_2D00_10_2D00_13_2D00_01.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/8304.hsg_2D00_2_2D00_10_2D00_13_2D00_01.png" alt="Image of command output" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I could use the same custom table property technique to change the display of free space and capacity to display in gigabytes instead of bytes. That would be a decent amount of work, however, and it was not required by the event.&lt;/p&gt;
&lt;p&gt;I hope you find my description useful. When the second event ends, I will publish my solution to it as well. I am not certain that my code is what they were looking for, but it does meet the requirements. Hope you have a great weekend.&lt;/p&gt;
&lt;p&gt;Thank you, Scripting Wife&amp;mdash;nice write up. Join me tomorrow for 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;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3551489" width="1" height="1" alt="" /&gt;</description></item><item><title>Use PowerShell to Find the History of USB Flash Drive Usage</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2012/05/18/use-powershell-to-find-the-history-of-usb-flash-drive-usage.aspx</link><pubDate>Fri, 18 May 2012 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:16607</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;b&gt;Summary&lt;/b&gt;: Microsoft premier field engineer, Jason Walker, shows how to use Windows PowerShell to get a history of USB drive usage.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Microsoft Scripting Guy, Ed Wilson, is here. I was talking to Jason Walker at the Charlotte Windows PowerShell User Group the other day. I asked him what cool things he was doing with Windows PowerShell, and he discussed a script he had recently written. I encouraged him to write a guest blog about the script. Today&amp;rsquo;s blog is a result of that conversation.&lt;/p&gt;
&lt;p&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/5381.HSG_2D00_5_2D00_18_2D00_12_2D00_1.png"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/150x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5381.HSG_2D00_5_2D00_18_2D00_12_2D00_1.png" alt="Photo of Jason Walker" title="Photo of Jason Walker" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Jason Walker is a premier field engineer (PFE) at Microsoft, and he supports customers in the public arena. His primary job is supporting Exchange Server, but he jumps at the opportunity to flex his Windows PowerShell muscles to resolve any issue that may come up. It does not matter if it is related to Exchange Server. Jason also actively participates in the &lt;a href="http://powershellgroup.org/charlotte.nc" target="_blank"&gt;Charlotte PowerShell Users Group&lt;/a&gt;.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Twitter: &lt;a href="http://twitter.com/#!/AutomationJason" target="_blank"&gt;AutomationJason&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;USB ports are an awesome resource to any computer. They allow you quickly connect and use accessories such as mice, keyboards, and storage devices, just to name a few. However, USB storage devices are a popular vector bad guys use to get nefarious code onto a machine. With my customers being in the public sector, security is a top priority, and USB storage devices are not allowed. We could disable USB ports all together, but that would eliminate the ability to use other USB devices. Therefore, users are told to simply not use USB storage devices. The need came up to see if the users are playing by the rules and Windows PowerShell was the answer to that need.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;How do we find out if a USB storage device has been connect to a computer?&amp;rdquo; you ask. We look in the registry, of course. When a USB storage device is inserted into a machine, the USBSTOR key is created in the registry, and everything the operating system needs to know about that storage device is contained in that key. This is the complete path:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;/p&gt;
&lt;p&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/5353.hsg_2D00_5_2D00_18_2D00_12_2D00_2.png"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/350x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/5353.hsg_2D00_5_2D00_18_2D00_12_2D00_2.png" alt="Image of menu" title="Image of menu" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When we expand the USBSTOR key, we see all the USB storage devices that have been used on the computer.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&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/2664.hsg_2D00_5_2D00_18_2D00_12_2D00_3.png"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/350x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/2664.hsg_2D00_5_2D00_18_2D00_12_2D00_3.png" alt="Image of menu" title="Image of menu" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We see here that 15 different USB storage devices have been used on this machine. I know what you are thinking: &amp;ldquo;Whoever owns this machine is not very security conscience!&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;By looking at the subkey names, we can get an idea about what kind of storage device was used, but the data isn&amp;rsquo;t easily readable. When we dig deeper, we find a &lt;b&gt;FriendlyName&lt;/b&gt; property that is easily readable.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&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/7411.hsg_2D00_5_2D00_18_2D00_12_2D00_4.png"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/7411.hsg_2D00_5_2D00_18_2D00_12_2D00_4.png" alt="Image of menu" title="Image of menu" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now we can see that a &amp;ldquo;SanDisk U3 Cruzer Micro USB Device&amp;rdquo; was used on this machine.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;To get this information, all we need Windows PowerShell to do is start from the USBSTOR key, recurse down two subkeys, and grab the &lt;b&gt;FriendlyName&lt;/b&gt; property. There are a couple ways we can get this data. We could do it in one line like this:&lt;/p&gt;
&lt;p&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/8463.hsg_2D00_5_2D00_18_2D00_12_2D00_5.png"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/8463.hsg_2D00_5_2D00_18_2D00_12_2D00_5.png" alt="Image of command output" title="Image of command output" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But if we want to get this data from a remote machine, this will not work unless Windows PowerShell remoting is enabled&amp;mdash;and it most cases it is not. I believe the method that will work in the most number of scenarios is the Microsoft.Win32.RegistryKey class.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;b&gt;Note&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/b&gt;If you have Windows PowerShell remoting enabled, see last week&amp;rsquo;s Hey, Scripting Guy! blogs for a different approach to working with the registry. Saturday&amp;rsquo;s blog, &lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/05/12/weekend-scripter-use-powershell-to-easily-modify-registry-property-values.aspx" target="_blank"&gt;Use PowerShell to Easily Modify Registry Property Values&lt;/a&gt;, contains links to the entire series.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I will explain the code that does all the heavy lifting.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;First, starting at USBSTOR, we get all the subkeys:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Hive,$Computer)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$USBSTORKey = $Reg.OpenSubKey($Key)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;$USBSTORSubKeys1 = $USBSTORKey.GetSubKeyNames()&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Then we go through each subkey ($USBSTORSubkeys1) and collect the child subkeys. We store them in $SubKeys2 as shown here:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;ForEach($SubKey1 in $USBSTORSubKeys1)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&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;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; $Key2 = &amp;quot;SYSTEM\CurrentControlSet\Enum\USBSTOR\$SubKey1&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; $RegSubKey2 = $Reg.OpenSubKey($Key2)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; $SubkeyName2 = $RegSubKey2.GetSubKeyNames()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; $Subkeys2 &amp;nbsp;+= &amp;quot;$Key2\$SubKeyName2&amp;quot;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; $RegSubKey2.Close()&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;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; }#end foreach SubKey1&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now we go through each Key in $Subkey2 and grab the &lt;b&gt;FriendlyName&lt;/b&gt; property of the key. The value of the property and the name of the computer are stored in a custom object so we can easily send our data to &lt;b&gt;Export-CSV&lt;/b&gt; or filter with &lt;b&gt;Where-Object&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;ForEach($Subkey2 in $Subkeys2)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&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;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; $USBKey&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;= $Reg.OpenSubKey($Subkey2)&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; $USBDevice&amp;nbsp; = $USBKey.GetValue(&amp;#39;FriendlyName&amp;#39;)&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;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp; $USBDevices += New-Object &amp;ndash;TypeName PSObject -Property @{&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&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; USBDevice = $USBDevice&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&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; Computer = $Computer&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&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;}&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&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;$USBKey.Close()&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&amp;nbsp;&amp;nbsp;}#end foreach SubKey2&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;A few things to note are that the Remote Registry service must be running on the remote machine. I added a &lt;b&gt;Write-Progress&lt;/b&gt; cmdlet because when I first wrote this script it ran against hundreds of machines. The &lt;b&gt;Test-Connection&lt;/b&gt; cmdlet is not needed because the connection to the remote machine is inside the Try\Catch. However, during testing, it took 30+ seconds for the script to move to the next computer when trying to connect to a machine that was not online, so I added that as an option.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The script is written as a function, and it has comment-based Help with examples. Because it is written as a function, it will need to be dot-sourced. This is done by placing a dot and a space in front of the path to the script. When this is done, you can use the function just as you would a native Windows PowerShell cmdlet. Here is an example of how this is done:&lt;/p&gt;
&lt;p&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/6472.hsg_2D00_5_2D00_18_2D00_12_2D00_6.png"&gt;&lt;img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-76-18/6472.hsg_2D00_5_2D00_18_2D00_12_2D00_6.png" alt="Image of command output" title="Image of command output" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks, and I hope you can find this script useful when it&amp;rsquo;s time for you to flex your Windows PowerShell muscles.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;~Jason&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The complete script can be downloaded from the &lt;a href="http://gallery.technet.microsoft.com/scriptcenter/Get-USBHistory-707e43a3" target="_blank"&gt;Script Repository&lt;/a&gt;. Thank you for a great guest blog. I have often seen this registry key, but never thought about using it in the way you have here. Awesome job.&lt;/p&gt;
&lt;p&gt;&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;/p&gt;
&lt;p&gt;&lt;b&gt;Ed Wilson, Microsoft Scripting Guy&lt;/b&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3498124" width="1" height="1" alt="" /&gt;</description></item><item><title>Use PowerShell to Determine Fragmentation of Your Drive</title><link>http://powershell.com/cs/blogs/hey-scriptingguy/archive/2011/03/15/use-powershell-to-determine-fragmentation-of-your-drive.aspx</link><pubDate>Tue, 15 Mar 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:9652</guid><dc:creator>Anonymous</dc:creator><description>Summary : Learn how to use Windows PowerShell to determine the amount of fragmentation of your hard disk drives. Hey, Scripting Guy! One of the things that annoys me is that the &amp;ldquo;new&amp;rdquo; defragmenter program in Windows 7 does not return any information...(&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/03/15/use-powershell-to-determine-fragmentation-of-your-drive.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3412638" width="1" height="1" alt="" /&gt;</description></item></channel></rss>