{"id":16921,"date":"2010-10-04T00:01:00","date_gmt":"2010-10-04T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2010\/10\/04\/use-powershell-to-gauge-the-reliability-of-your-windows-7-computer\/"},"modified":"2010-10-04T00:01:00","modified_gmt":"2010-10-04T00:01:00","slug":"use-powershell-to-gauge-the-reliability-of-your-windows-7-computer","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-powershell-to-gauge-the-reliability-of-your-windows-7-computer\/","title":{"rendered":"Use PowerShell to Gauge the Reliability of Your Windows 7 Computer"},"content":{"rendered":"<p><span style=\"font-size: 10pt\"><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: arial,helvetica,sans-serif\"><\/span><br \/><strong>Summary<\/strong>: The Microsoft Scripting Guys show you how to use Windows PowerShell to determine the reliability of your Windows 7 or Window Server 2008 R2 computer.<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\"><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Question\" border=\"0\" title=\"Hey, Scripting Guy! Question\" \/>Hey, Scripting Guy! Our CIO is a rather strange creature. He seems to go missing for weeks on end, and then suddenly he will appear in the server room, create havoc, and leave. He&rsquo;s our poltergeist. Today was the day for his bimonthly apparition. So there I was, diligently reviewing event logs on my assigned servers, when suddenly I feel the temperature rise several degrees. The hair on the back of my neck seemed to stand on end (this might be a good time to tell you that our CIO in addition, to being spectral in his countenance, is a rather large being who radiates heat on even the coldest days). I turned around and asked him, &ldquo;Can I help you?&rdquo; He then asked if I could show the reliability of our newly deployed Windows Server 2008 R2 servers. I started to offer him the current uptime report that I run each day, but he said, &ldquo;No! I want reliability not uptime. Get it for me by the end of the week.&rdquo; <a href=\"http:\/\/en.wikipedia.org\/wiki\/Dude\"><span style=\"color: #0000ff\"><span style=\"font-family: arial,helvetica,sans-serif\">Dude<\/span><\/span><\/a>! I have no idea what he is talking about. Do you?<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">&#8212; SC<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\"><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Answer\" border=\"0\" title=\"Hey, Scripting Guy! Answer\" \/> Hello SC, <\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">Microsoft Scripting Guy Ed Wilson here. Recently, I had the opportunity to speak at <a href=\"http:\/\/www.sqlsaturday.com\/\"><span style=\"color: #0000ff\"><span style=\"font-family: arial,helvetica,sans-serif\">SQL Saturday<\/span><\/span><\/a><span style=\"font-family: arial,helvetica,sans-serif\"> <\/span>in Raleigh, <a href=\"http:\/\/en.wikipedia.org\/wiki\/North_Carolina\"><span style=\"color: #0000ff\"><span style=\"font-family: arial,helvetica,sans-serif\">North Carolina<\/span><\/span><\/a>, in the United States. Because Raleigh is a four-hour drive from Charlotte, I sat in the passenger seat and spent the time exploring Windows Management Instrumentation (<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/aa394582(VS.85).aspx\"><span style=\"color: #0000ff\"><span style=\"font-family: arial,helvetica,sans-serif\">WMI<\/span><\/span><\/a>) classes. This is actually one of my favorite things to do, and I found a few WMI classes that looked particularly interesting. The classes all include the word <i>reliability<\/i> in their name. I will show you some of the things I found in just a bit. By the way, SQL Saturday was a lot of fun. I was there talking about Windows PowerShell Best Practices. The following photo was taken during the session. <\/span><\/p>\n<p class=\"Num-Caption\"><span style=\"font-size: 10pt\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6403.HSG-10-04-10-01.jpg\" alt=\"Photo of Ed Wilson speaking at SQL Saturday\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" \/><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">Anyway, SC, back to your question. Let me show you a really cool trick for finding WMI classes. You probably know that you can use the <strong>Get-WmiObject<\/strong> cmdlet with the <strong>&ndash;list<\/strong> switch to produce a listing of WMI class names. But did you know you can also filter that list? This is shown here:<\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">PS C:\\&gt; Get-WmiObject -List &#8220;*reliabil*&#8221; <\/p>\n<p><span>&nbsp;&nbsp; <\/span>NameSpace: ROOT\\cimv2 <\/p>\n<p>Name<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Methods<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Properties <br \/>&#8212;-<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>&#8212;&#8212;-<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>&#8212;&#8212;&#8212;- <br \/>Win32_Reliability<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{} <br \/>Win32_ReliabilityStabilityMetrics<span>&nbsp;&nbsp; <\/span>{GetRecordCount}<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{EndMeasurementDate, Rel&#8230; <br \/>Win32_ReliabilityRecords<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{GetRecordCount}<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{ComputerName, EventIden&#8230; <\/p>\n<p>PS C:\\&gt;<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">Therefore, three WMI classes have the word Reliability in their name. <\/span><\/p>\n<p class=\"Readeraidonly\"><strong><span style=\"font-size: 10pt\">Note<\/span><\/strong><span style=\"font-size: 10pt\">: The WMI Reliability provider exists only on Windows 7 and Windows Server 2008 R2 (and later). It is enabled by default on Windows 7 computers, but must be specifically enabled via the &ldquo;Configure Reliability WMI Providers&rdquo; Group Policy setting for the server operating system. <\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">Because I was riding in the passenger seat of a motor vehicle that was traveling 65 miles per hour down the interstate, and I did not have access to the Internet, I did not have access to the MSDN documentation. Back when I was traveling every week, I used to download and install Windows SDK documentation on my laptop, but that consumes a huge chunk of my pitifully small laptop hard drive, and nowadays I always access the documentation via the Internet. The problem comes during road trips. However, this is not a problem in one knows how to use the tools that are inherent to Windows WMI implementations. <a href=\"http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2009\/08\/04\/hey-scripting-guy-how-do-i-use-wmi-with-windows-powershell-to-return-information-about-properties.aspx\"><span style=\"color: #0000ff\"><span style=\"font-family: arial,helvetica,sans-serif\">Using wbemtest<\/span><\/span><\/a>, I opened the first WMI class that was listed. The results are shown in the following image. The thing that is the most important to recognize is that the <strong>Win32_Reliability<\/strong> class is an abstract class. <\/span><\/p>\n<p class=\"Num-Caption\"><span style=\"font-size: 10pt\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6724.HSG-10-04-10-02.jpg\" alt=\"Image showing the Win32_Reliability class is abstract class\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" \/><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">I then looked at the classes that are derived from this class. They are shown in the following image.<\/span><\/p>\n<p class=\"Num-Caption\"><span style=\"font-size: 10pt\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4520.HSG-10-04-10-03.jpg\" alt=\"Image of classes derived from Win32_Reliability class\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" \/><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">It is possible to query an abstract class, but the results are unreliable and unsupported. One thing that is confusing is that when querying an abstract class, the results that are returned come from the derived classes and not the abstract itself. In our example, the <strong>Win32_Reliability<\/strong> WMI class has two classes that are derived from it: <strong>Win32_ReliabilityStabilityMetrics<\/strong> and <strong>Win32_ReliabilityRecords<\/strong>. To see that the results are returned from the derived class, you need to query the abstract. Note that the <strong>__CLASS<\/strong> system property tells us the class that returns the information. In this example, it is the <strong>Win32_ReliabilityStabilityMetrics<\/strong> class. Note also that the <strong>__RELPATH<\/strong> system property (relative path) and the <strong>__PATH<\/strong> property point to the <strong>Win32_ReliabilityStabilityMetrics<\/strong> class as well. The <strong>__SUPERCLASS<\/strong> property (I call it the &ldquo;who&rsquo;s your daddy&rdquo; property) gives us the parent class or the class from whence the current class is derived. The system properties, therefore, tell us that <strong>Win32_Reliability<\/strong> did not answer our WMI query; rather, it was the <strong>Win32_ReliabilityStabilityMetrics<\/strong> class that responded to our question. The output is shown here: <\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">PS C:\\&gt; Get-WmiObject -Class win32_reliability | Select-Object -First 1 <\/p>\n<p>__GENUS<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: 2 <br \/>__CLASS<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: Win32_ReliabilityStabilityMetrics <br \/>__SUPERCLASS<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: Win32_Reliability <br \/>__DYNASTY<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: Win32_Reliability <br \/>__RELPATH<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: Win32_ReliabilityStabilityMetrics.TimeGenerated=&#8221;201009231500 <br \/><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>00.000000-000&#8243; <br \/>__PROPERTY_COUNT<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: 5 <br \/>__DERIVATION<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: {Win32_Reliability} <br \/>__SERVER<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: MRED1 <br \/>__NAMESPACE<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: root\\cimv2 <br \/>__PATH<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: \\\\MRED1\\root\\cimv2:Win32_ReliabilityStabilityMetrics.TimeGene <br \/><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>rated=&#8221;20100923150000.000000-000&#8243; <br \/>EndMeasurementDate<span>&nbsp;&nbsp; <\/span>: 20100923150000.000000-000 <br \/>RelID<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: {806265F0-CDBC-4078-84D8-53EEB08CCA22} <br \/>StartMeasurementDate : 20100923140000.000000-000 <br \/>SystemStabilityIndex : 3.449 <br \/>TimeGenerated<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>: 20100923150000.000000-000 <\/p>\n<p>PS C:\\&gt;<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">Just for fun, I thought I would use the abstract <strong>Win32_Reliability<\/strong> class to provide a breakdown between the number <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ee198910.aspx\"><span style=\"color: #0000ff\"><span style=\"font-family: arial,helvetica,sans-serif\">for each<\/span><\/span><\/a><span style=\"font-family: arial,helvetica,sans-serif\"> <\/span>of the two derived classes. Here is the command I typed into my Windows PowerShell console:<\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">PS C:\\&gt; GWMI win32_reliability | group<span>&nbsp; <\/span>__class | ft name, count -A <\/p>\n<p>Name<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Count <br \/>&#8212;-<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>&#8212;&#8211; <br \/>Win32_ReliabilityStabilityMetrics<span>&nbsp; <\/span>8005 <br \/>Win32_ReliabilityRecords<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>2222<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">That command expands when not using the aliases. Here is the same command without using the aliases. <\/span><\/p>\n<blockquote>\n<p class=\"CodeBlockScreenedHead\"><strong><span style=\"font-size: small\">Get-ReliabilityBreakDown.ps1<\/span><\/strong><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">Get-WmiObject -Class win32_reliability -ComputerName .| <br \/>Group-Object -Property __class | <br \/>Format-Table -Property name, count &ndash;AutoSize<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">I then decided to write a script that will pull out the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ee706632(VS.85).aspx\"><span style=\"color: #0000ff\"><span style=\"font-family: arial,helvetica,sans-serif\">win32_reliabilityStabilityMetrics<\/span><\/span><\/a><span style=\"font-family: arial,helvetica,sans-serif\"> <\/span>for my computer. The Get-ReliabilityMetrics.ps1<strong> <\/strong>script is shown here. <\/span><\/p>\n<blockquote>\n<p class=\"CodeBlockScreenedHead\"><strong><span style=\"font-size: small\">Get-ReliabilityMetrics.ps1<\/span><\/strong><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">&#8220;Processing $((Get-WmiObject -Class win32_reliabilityStabilityMetrics).count) records&#8221;<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">Get-WmiObject -Class win32_reliabilityStabilityMetrics |<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">Format-Table -Property @{Label = &#8220;time&#8221;; Expression = `<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">{[Management.ManagementDatetimeConverter]::ToDateTime($_.TimeGenerated)} }, <\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\"><span>&nbsp;<\/span>SystemStabilityIndex -autosize<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">The first line uses the <strong>count<\/strong> method from the WMI class to display a notation about how many reliability records are to be processed. This is meant as a status indicator to let you know the script is working. Because a subexpression is required to force evaluation of the WMI object before calling the <strong>count<\/strong> method, the code looks a bit strange with several parentheses. This is shown here:<\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">&#8220;Processing $((Get-WmiObject -Class win32_reliabilityStabilityMetrics).count) records&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">If you did not use a subexpression, concatenation would be required to display the number of records inside a string. To me, I prefer to use the subexpression inside the expanding quotation marks rather than use the concatenation that is shown here:<\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">&#8220;Processing &#8221; + (Get-WmiObject -Class win32_reliabilityStabilityMetrics).count + &#8221; records&#8221;<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">The basic WMI query is performed with the <strong>Get-WMiObject<\/strong> cmdlet, and the results are piped to the <strong>Format-Table<\/strong> cmdlet. This is shown here: <\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">Get-WmiObject -Class win32_reliabilityStabilityMetrics |<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">If you need to target a remote computer, use the <strong>&ndash;computername<\/strong> parameter; use the <strong>&ndash;credential<\/strong> parameter if alternate credentials are required: <\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">PS C:\\&gt; Get-WmiObject -Class win32_reliabilityStabilityMetrics -ComputerName cdc1 -Credential contoso\\administrator<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">When the code seen above runs, the credential dialog box appears that is shown in the following image:<\/span><\/p>\n<p class=\"Num-Caption\"><span style=\"font-size: 10pt\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7762.HSG-10-04-10-04.jpg\" alt=\"Image of credential dialog box that appears when code runs\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" \/><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">The most complicated portion of the script uses a hash table to create a custom property in the <strong>Format-Table<\/strong> command. WMI time is difficult to read, as shown here: <\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">20100911100000.000000-000<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">The time seen above is the year 2010, the month is September, the day is the eleventh, and the time is 1000 GMT. It makes more sense to translate that time into something more readable. Years ago, the Microsoft Scripting Guys wrote a custom function that used string manipulation to convert the long series of numbers into a more readable format. Nowadays, such a function is neither necessary nor desired. The .NET Framework includes the <strong>ManagementDateTimeConverter<\/strong> class in the <strong>System.Management<\/strong> namespace. The word <strong>System<\/strong> is left off because Windows PowerShell assumes that everything is included under the <strong>System<\/strong> root namespace. The <strong>ToDateTime<\/strong> method is static and will convert the WMI time into a more readable time string. The method can be called directly as shown here where I translate the above WMI date:<\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">PS C:\\&gt; [Management.ManagementDatetimeConverter]::ToDateTime(&#8220;20100911100000.000000-0<\/span><\/span><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">00&#8243;)<\/span><\/span><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">&nbsp;<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">Saturday, September 11, 2010 6:00:00 AM<\/span><\/span><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">&nbsp;<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">PS C:\\&gt;<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">This portion of the script is shown here: <\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">Format-Table -Property @{Label = &#8220;time&#8221;; Expression = `<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\">{[Management.ManagementDatetimeConverter]::ToDateTime($_.TimeGenerated)} }, <\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: lucida sans typewriter\"><span>&nbsp;<\/span>SystemStabilityIndex &ndash;autosize<\/span><\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">One thing to keep in mind is that the use of the <strong>&ndash;autosize<\/strong> switch to tighten up the output display significantly slows down the script. It makes for an easier output to read, as shown in the following image.<\/span><\/p>\n<p class=\"Num-Caption\"><span style=\"font-size: 10pt\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8765.HSG-10-04-10-05.jpg\" alt=\"Image of easier ouput to read with use of -autosize switch\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" \/><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">Windows PowerShell has to process each of the 8,003 records on my computer, determine how much space is required for displaying the output, and then display the output. Without this switch, the output fills the output pane of the Windows PowerShell ISE or the Windows PowerShell console, as shown in the following image. <\/span><\/p>\n<p class=\"Num-Caption\"><span style=\"font-size: 10pt\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1401.HSG-10-04-10-06.jpg\" alt=\"Image of output without switch\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" \/><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\"><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">SC, that is all there is to using the <strong>Win32_Reliability<\/strong> WMI classes. Reliability Week will continue tomorrow when we will talk about filtering reliability records. <\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\">We invite you to follow us on <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguystwitter\"><span style=\"color: #0000ff\"><span style=\"font-family: arial,helvetica,sans-serif\">Twitter<\/span><\/span><\/a><span style=\"font-family: arial,helvetica,sans-serif\"> <\/span>and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\"><span style=\"color: #0000ff\"><span style=\"font-family: arial,helvetica,sans-serif\">Facebook<\/span><\/span><\/a>. If you have any questions, send email to us at <a target=\"_blank\" href=\"mailto:scripter@microsoft.com\"><span style=\"color: #0000ff\"><span style=\"font-family: arial,helvetica,sans-serif\">scripter@microsoft.com<\/span><\/span><\/a>, or post your questions on the <a href=\"http:\/\/social.technet.microsoft.com\/Forums\/en\/ITCG\/threads\/\"><span style=\"color: #0000ff\"><span style=\"font-family: arial,helvetica,sans-serif\">Official Scripting Guys Forum<\/span><\/span><\/a>. See you tomorrow. Until then, peace.<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt;font-family: 'Segoe UI','sans-serif'\">&nbsp;<\/span><\/p>\n<p><strong><span style=\"font-size: 10pt;font-family: 'Segoe UI','sans-serif'\">Ed Wilson and Craig Liebendorfer, Scripting Guys<\/span><\/strong><\/p>\n<p><strong><span style=\"font-size: 10pt;font-family: 'Segoe UI','sans-serif'\"><\/span><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: The Microsoft Scripting Guys show you how to use Windows PowerShell to determine the reliability of your Windows 7 or Window Server 2008 R2 computer. &nbsp; &nbsp; Hey, Scripting Guy! Our CIO is a rather strange creature. He seems to go missing for weeks on end, and then suddenly he will appear in the [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[31,60,3,45],"class_list":["post-16921","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-operating-system","tag-performance","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: The Microsoft Scripting Guys show you how to use Windows PowerShell to determine the reliability of your Windows 7 or Window Server 2008 R2 computer. &nbsp; &nbsp; Hey, Scripting Guy! Our CIO is a rather strange creature. He seems to go missing for weeks on end, and then suddenly he will appear in the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=16921"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16921\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=16921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=16921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=16921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}