{"id":16911,"date":"2010-10-05T00:01:00","date_gmt":"2010-10-05T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2010\/10\/05\/use-powershell-to-graph-the-reliability-of-windows-2008-r2\/"},"modified":"2010-10-05T00:01:00","modified_gmt":"2010-10-05T00:01:00","slug":"use-powershell-to-graph-the-reliability-of-windows-2008-r2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-powershell-to-graph-the-reliability-of-windows-2008-r2\/","title":{"rendered":"Use PowerShell to Graph the Reliability of Windows 2008 R2"},"content":{"rendered":"<p><b>Summary<\/b>: Microsoft Scripting Guy Ed Wilson shows you how to use Group Policy to enable reliability tracing via Windows PowerShell and Microsoft Graph.<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" border=\"0\" align=\"left\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" height=\"34\" title=\"Hey, Scripting Guy! Question\" \/><\/p>\n<p>Hey, Scripting Guy! First of all, let me say that yesterday&rsquo;s article was interesting. We are also looking at attempting to determine server reliability, and I think that the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/aa394582(VS.85).aspx\">WMI<\/a> Reliability provider may provide just what we need. However, when I attempted to run your commands on our Windows Server 2008 R2 servers, I got an error. Is your code broken? Say it ain&rsquo;t so!<\/p>\n<p>&#8212; DA<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" border=\"0\" align=\"left\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" height=\"34\" title=\"Hey, Scripting Guy! Answer\" \/><\/p>\n<p>Hello DA, <\/p>\n<p>Microsoft Scripting Guy Ed Wilson here. Fall in the Deep South is absolutely my favorite time of the year. <a href=\"http:\/\/www.sqlsaturday.com\/\">SQLSaturday<\/a> in Columbia, South Carolina, was a great event. I had the opportunity to meet several people I had been following on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a>, and found new database administrators who are active in the SQL community. In addition to the networking, the sessions were awesome. <\/p>\n<p>GP, to gain access to the WMI classes that are supplied by the Reliability provider on a Windows Server 2008 R2 computer, you need to first enable the provider via Group Policy. On <a href=\"http:\/\/www.microsoft.com\/windows\/windows-7\/default.aspx\">Windows 7<\/a>, the provider is enabled by default. <\/p>\n<p>There are two things about Group Policy. The first, as shown in the following image, is that there are several thousand policy settings (luckily there is a <a href=\"http:\/\/www.microsoft.com\/downloads\/en\/details.aspx?FamilyID=18c90c80-8b0a-4906-a4f5-ff24cc2030fb&amp;displaylang=en\">Group Policy spreadsheet<\/a> that you can download for reference) in the Group Policy Management Editor.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5732.HSG-10-05-10-01_122EBE62.jpg\"><img decoding=\"async\" border=\"0\" width=\"554\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8284.HSG-10-05-10-01_thumb_55B649B7.jpg\" alt=\"Image showing some of several thousand policy settings in Group Policy Management Editor\" height=\"387\" style=\"border-top-width: 0px;padding-right: 0px;padding-left: 0px;border-left-width: 0px;border-bottom-width: 0px;padding-top: 0px;border-right-width: 0px\" title=\"Image showing some of several thousand policy settings in Group Policy Management Editor\" \/><\/a><\/p>\n<p>The second thing you need to know about Group Policy is that there is an excellent search feature. Unfortunately, the feature is not called search or even find; it is called filter. The Filter Options dialog box is shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8360.HSG-10-05-10-02_143B975E.jpg\"><img decoding=\"async\" border=\"0\" width=\"404\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7128.HSG-10-05-10-02_thumb_6C951B33.jpg\" alt=\"Image of Filter Options dialog box\" height=\"479\" style=\"border-top-width: 0px;padding-right: 0px;padding-left: 0px;border-left-width: 0px;border-bottom-width: 0px;padding-top: 0px;border-right-width: 0px\" title=\"Image of Filter Options dialog box\" \/><\/a><\/p>\n<p>After I apply the filter, only the Configure Reliability WMI Providers policy setting remains, as shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3580.HSG-10-05-10-03_12F6FE7F.jpg\"><img decoding=\"async\" border=\"0\" width=\"554\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4666.HSG-10-05-10-03_thumb_044C529A.jpg\" alt=\"Image showing only Configure Reliability WMI Providers remains after filter applied\" height=\"387\" style=\"border-top-width: 0px;padding-right: 0px;padding-left: 0px;border-left-width: 0px;border-bottom-width: 0px;padding-top: 0px;border-right-width: 0px\" title=\"Image showing only Configure Reliability WMI Providers remains after filter applied\" \/><\/a><\/p>\n<p>The Configure Reliability WMI Providers policy setting is a simple setting: enable or disable. This is shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5141.HSG-10-05-10-04_11B265A0.jpg\"><img decoding=\"async\" border=\"0\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2018.HSG-10-05-10-04_thumb_1C038A00.jpg\" alt=\"Image of policy setting being enable or disable\" height=\"552\" style=\"border-top-width: 0px;padding-right: 0px;padding-left: 0px;border-left-width: 0px;border-bottom-width: 0px;padding-top: 0px;border-right-width: 0px\" title=\"Image of policy setting being enable or disable\" \/><\/a><\/p>\n<p>After the Group Policy setting has been enabled, you will need to refresh the Group Policy settings on your servers. Updating Group Policy settings can easily be accomplished from the Windows PowerShell console. <\/p>\n<p>The first thing I need to do is store administrative credentials in a variable. I do this by using the <b>Get-Credential<\/b> cmdlet. A message appears in the Windows PowerShell console as shown here: <\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\">PS<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">C:\\&gt;<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$credential<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Get-Credential<\/span><span style=\"color: #808080\">&nbsp; <\/p>\n<p><\/span><span style=\"color: #000000\">cmdlet<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Get-Credential<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">at<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">command<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">pipeline<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">position<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">Supply<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">values<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">for<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">following<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">parameters:<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">Credential<\/span> <\/div>\n<\/blockquote>\n<p>In addition, the dialog box shown in the following image allows me to securely type the user name and password.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7624.HSG-10-05-10-05_5B613D90.jpg\"><img decoding=\"async\" border=\"0\" width=\"354\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7215.HSG-10-05-10-05_thumb_7DB8D309.jpg\" alt=\"Image showing credentials dialog box \" height=\"277\" style=\"border-top-width: 0px;padding-right: 0px;padding-left: 0px;border-left-width: 0px;border-bottom-width: 0px;padding-top: 0px;border-right-width: 0px\" title=\"Image showing credentials dialog box \" \/><\/a><\/p>\n<p>I then use the <b>Get-Content<\/b> cmdlet to read a text file that contains a listing of the servers upon which I wish to operate. The text file simply contains each computer name on an individual line as shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5545.HSG-10-05-10-06_613BE129.jpg\"><img decoding=\"async\" border=\"0\" width=\"354\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4555.HSG-10-05-10-06_thumb_55A623EA.jpg\" alt=\"Image of text file with computer names\" height=\"240\" style=\"border-top-width: 0px;padding-right: 0px;padding-left: 0px;border-left-width: 0px;border-bottom-width: 0px;padding-top: 0px;border-right-width: 0px\" title=\"Image of text file with computer names\" \/><\/a><\/p>\n<p>I pipe the results of the <b>Get-Content<\/b> cmdlet to the <a href=\"http:\/\/www.bing.com\/visualsearch?g=powershell_cmdlets&amp;FORM=Z9GE22\">ForEach-Object cmdlet<\/a>, and call the <b>Invoke-Command<\/b> cmdlet. I pass the name of the current computer name to the <b>&ndash;computername<\/b> parameter, the credential that is stored in the <b>$credential<\/b> variable to the <b>&ndash;credential<\/b> parameter, and the <b>gpupdate \/force<\/b> command to the <b>scriptblock<\/b> parameter. The command (which is a single line) is shown here:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\">PS<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">C:\\&gt;<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Get-Content<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">C:\\fso\\Servers.txt<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">ForEach-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Invoke-Command<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-ComputerNam<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">e<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Credential<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$credential<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-ScriptBlock<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">gpupdate<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">\/force<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">}<\/span> <\/div>\n<\/blockquote>\n<p>The output from running the command is shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7624.HSG-10-05-10-07_351EE438.jpg\"><img decoding=\"async\" border=\"0\" width=\"504\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7612.HSG-10-05-10-07_thumb_4623121B.jpg\" alt=\"Image of output from running command\" height=\"508\" style=\"border-top-width: 0px;padding-right: 0px;padding-left: 0px;border-left-width: 0px;border-bottom-width: 0px;padding-top: 0px;border-right-width: 0px\" title=\"Image of output from running command\" \/><\/a><\/p>\n<p>As shown in the output above, the computer DC1 was unreachable. A quick <a href=\"http:\/\/en.wikipedia.org\/wiki\/Ping\">ping<\/a> confirms it is up and running. This tells me that Windows PowerShell remoting has not been enabled on that computer. I pop over to the DC1 box, open the Windows PowerShell console, and type enable-psremoting &ndash;force (Because DC1 is a server and administrator rights are required to log on to the console, I do not have to open an &ldquo;elevated&rdquo; Windows PowerShell console; UAC is disabled on that server.)<\/p>\n<p>After Group Policy has been updated on the Windows Server 2008 R2 machines, you will not be able to query the servers until several hours have passed, and the machines have had an opportunity to create reliability stability metrics that are retrieved via the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ee706632(VS.85).aspx\">Win32_ReliabilityStabilityMetrics<\/a> class. Rather than trying to weed through a bunch of data, it might make sense to write a nice script. A sample of the raw data is shown here:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\">PS<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">C:\\&gt;<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Get-WmiObject<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Class<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">win32_reliabilityStabilityMetrics<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-ComputerName<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">hyperv-box<\/span><span style=\"color: #808080\">&nbsp; <\/p>\n<p><\/span><span style=\"color: #000000\">__GENUS<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">2<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__CLASS<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Win32_ReliabilityStabilityMetrics<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__SUPERCLASS<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Win32_Reliability<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__DYNASTY<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Win32_Reliability<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__RELPATH<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Win32_ReliabilityStabilityMetrics.TimeGenerated<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&#8220;201009241900&nbsp; <br \/>00.000000-000&#8243;&nbsp; <br \/><\/span><span style=\"color: #000000\">__PROPERTY_COUNT<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">5<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__DERIVATION<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{Win32_Reliability}<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__SERVER<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">HYPERV-BOX<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__NAMESPACE<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">root\\cimv2<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__PATH<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">\\\\HYPERV-BOX\\root\\cimv2:Win32_ReliabilityStabilityMetrics.Tim<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">eGenerated<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&#8220;20100924190000.000000-000&#8221;&nbsp; <br \/><\/span><span style=\"color: #000000\">EndMeasurementDate<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">20100924190000<\/span><span style=\"color: #000000\">.000000-000<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">RelID<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{DE0BA634-C7D7-4D80-AEC3-08E604F96B0F}<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">StartMeasurementDate<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">20100924180000<\/span><span style=\"color: #000000\">.000000-000<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">SystemStabilityIndex<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">10<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">TimeGenerated<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">20100924190000<\/span><span style=\"color: #000000\">.000000-000<\/span><span style=\"color: #808080\">&nbsp; <\/p>\n<p><\/span><span style=\"color: #000000\">__GENUS<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">2<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__CLASS<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Win32_ReliabilityStabilityMetrics<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__SUPERCLASS<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Win32_Reliability<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__DYNASTY<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Win32_Reliability<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__RELPATH<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Win32_ReliabilityStabilityMetrics.TimeGenerated<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&#8220;201009241800&nbsp; <br \/>00.000000-000&#8243;&nbsp; <br \/><\/span><span style=\"color: #000000\">__PROPERTY_COUNT<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">5<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__DERIVATION<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{Win32_Reliability}<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__SERVER<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">HYPERV-BOX<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__NAMESPACE<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">root\\cimv2<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">__PATH<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">\\\\HYPERV-BOX\\root\\cimv2:Win32_ReliabilityStabilityMetrics.Tim<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">eGenerated<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&#8220;20100924180000.000000-000&#8221;&nbsp; <br \/><\/span><span style=\"color: #000000\">EndMeasurementDate<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">20100924180000<\/span><span style=\"color: #000000\">.000000-000<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">RelID<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{DE0BA634-C7D7-4D80-AEC3-08E604F96B0F}<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">StartMeasurementDate<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">20100924170000<\/span><span style=\"color: #000000\">.000000-000<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">SystemStabilityIndex<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">10<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">TimeGenerated<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">:<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">20100924180000<\/span><span style=\"color: #000000\">.000000-000<\/span> <\/div>\n<\/blockquote>\n<p>In fact, the best way to view this type of data is to create a chart. The easiest way to create a chart is to use the Microsoft Graph COM object. The use of the <b>Win32_ReliabilityStabilityMetrics<\/b> WMI class and the <b>[Management.ManagementDatetimeConverter]::ToDateTime<\/b> static method were discussed in <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2010\/10\/04\/use-powershell-to-gage-the-reliability-of-your-windows-7-computer.aspx\">yesterday&rsquo;s Hey, Scripting Guy! Blog post<\/a>. <\/p>\n<blockquote>\n<p><strong>New-ReliabilityChart.ps1<\/strong><\/p>\n<div class=\"code\"><span style=\"color: #2b91af\">$computer<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;localhost&#8221;&nbsp; <br \/><\/span><span style=\"color: #2b91af\">$chart<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">New-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-ComObject<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">msgraph.application<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #2b91af\">$chart<\/span><span style=\"color: #000000\">.visible<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$true<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #2b91af\">$chart<\/span><span style=\"color: #000000\">.datasheet.cells.item(<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;Time&#8221;&nbsp; <br \/><\/span><span style=\"color: #2b91af\">$chart<\/span><span style=\"color: #000000\">.datasheet.cells.item(<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #800000\">2<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;ReliabilityMetric&#8221;&nbsp; <br \/><\/span><span style=\"color: #2b91af\">$r<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">2<\/span><span style=\"color: #808080\">&nbsp; <\/p>\n<p><\/span><span style=\"color: #0000ff\">Get-WmiObject<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Class<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">win32_reliabilityStabilityMetrics<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-computername<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$computer<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">Select-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-First<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">254<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">ForEach-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp; <\/span><span style=\"color: #2b91af\">$chart<\/span><span style=\"color: #000000\">.datasheet.cells.item(<\/span><span style=\"color: #2b91af\">$r<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">`<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp; <\/span><span style=\"color: #000000\">[Management.ManagementDatetimeConverter]::ToDateTime(<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.TimeGenerated)<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp; <\/span><span style=\"color: #2b91af\">$chart<\/span><span style=\"color: #000000\">.datasheet.cells.item(<\/span><span style=\"color: #2b91af\">$r<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #800000\">2<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.SystemStabilityIndex<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #2b91af\">$r++<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">}<\/span> <\/div>\n<\/blockquote>\n<p>The <b>$computer<\/b> variable is used to hold the computer name. If the script were to be modified to run against multiple computers at the same time, you would need to modify the chart code to save each chart as the computer name, and maybe the date. The MSDN documentation for the Microsoft Graph object tells you how to save the chart. <\/p>\n<p>The <b>msgraph.application<\/b> program ID is used to create an instance of the Microsoft Graph application. The returned object is stored in the <b>$chart<\/b> variable. Next, the graph is made visible by setting the visible property to <b>$true<\/b>. This is shown here:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #2b91af\">$chart<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">New-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-ComObject<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">msgraph.application<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #2b91af\">$chart<\/span><span style=\"color: #000000\">.visible<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$true<\/span> <\/div>\n<\/blockquote>\n<p>Now I add two column headers: <b>time<\/b> and <b>ReliabilityMetric<\/b>. These go into the first row. I then set the value of <b>$r<\/b> to 2 (for the second row). This is shown here:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #2b91af\">$chart<\/span><span style=\"color: #000000\">.datasheet.cells.item(<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;Time&#8221;&nbsp; <br \/><\/span><span style=\"color: #2b91af\">$chart<\/span><span style=\"color: #000000\">.datasheet.cells.item(<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #800000\">2<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;ReliabilityMetric&#8221;&nbsp; <br \/><\/span><span style=\"color: #2b91af\">$r<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">2<\/span> <\/div>\n<\/blockquote>\n<p>I then query the <b>Win32_ReliabilityStabilityMetrics<\/b> WMI class and pipe the results to the <b>Select-Object<\/b> cmdlet to retrieve the first 254 objects (this is because the Microsoft Graph application is limited to 255 points). This is shown here:<\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\">Get-WmiObject<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Class<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">win32_reliabilityStabilityMetrics<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-computername<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$computer<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">Select-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-First<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">254<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span> <\/div>\n<\/blockquote>\n<p>The <b>Foreach-Object<\/b> cmdlet is used to allow us to write to each new row in the chart. This is shown here: <\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #0000ff\">ForEach-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp; <\/span><span style=\"color: #2b91af\">$chart<\/span><span style=\"color: #000000\">.datasheet.cells.item(<\/span><span style=\"color: #2b91af\">$r<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #800000\">1<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">`<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp; <\/span><span style=\"color: #000000\">[Management.ManagementDatetimeConverter]::ToDateTime(<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.TimeGenerated)<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp; <\/span><span style=\"color: #2b91af\">$chart<\/span><span style=\"color: #000000\">.datasheet.cells.item(<\/span><span style=\"color: #2b91af\">$r<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #800000\">2<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.SystemStabilityIndex<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #2b91af\">$r++<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">}<\/span> <\/div>\n<\/blockquote>\n<p>When the New-ReliabilityChart.ps1 script runs, the chart shown in the following image appears. As you can see, my Windows Server 2008 R2 server that is running Hyper-V currently has perfect reliability. <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3010.HSG-10-05-10-08_59CFFBAF.jpg\"><img decoding=\"async\" border=\"0\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5460.HSG-10-05-10-08_thumb_6A67F69D.jpg\" alt=\"Image of chart shown when script runs\" height=\"372\" style=\"border-top-width: 0px;padding-right: 0px;padding-left: 0px;border-left-width: 0px;border-bottom-width: 0px;padding-top: 0px;border-right-width: 0px\" title=\"Image of chart shown when script runs\" \/><\/a><\/p>\n<p>DA, that is all there is to using Windows PowerShell and WMI to work with the Reliability provider. Reliability Week will continue tomorrow when we will talk about parsing reliability data. <\/p>\n<p>We invite you to follow us on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to us at <a href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/social.technet.microsoft.com\/Forums\/en\/ITCG\/threads\/\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p>&nbsp;<\/p>\n<p><b>Ed Wilson and Craig Liebendorfer, Scripting Guys<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy Ed Wilson shows you how to use Group Policy to enable reliability tracing via Windows PowerShell and Microsoft Graph. &nbsp; Hey, Scripting Guy! First of all, let me say that yesterday&rsquo;s article was interesting. We are also looking at attempting to determine server reliability, and I think that the WMI Reliability [&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":[25,152,31,60,3,4,45,6],"class_list":["post-16911","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-displaying-output","tag-group-policy","tag-operating-system","tag-performance","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell","tag-wmi"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy Ed Wilson shows you how to use Group Policy to enable reliability tracing via Windows PowerShell and Microsoft Graph. &nbsp; Hey, Scripting Guy! First of all, let me say that yesterday&rsquo;s article was interesting. We are also looking at attempting to determine server reliability, and I think that the WMI Reliability [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16911","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=16911"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16911\/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=16911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=16911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=16911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}