<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Matt Bielman</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/mattbie/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/mattbie/feed.xml</link>
    <description>Troubleshooting, Support Automation, and fun with technology</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:17:22 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Running a troubleshooter from the command line</title>
      <link>https://docs.microsoft.com/archive/blogs/mattbie/running-a-troubleshooter-from-the-command-line</link>
      <pubDate>Tue, 09 Nov 2010 12:22:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Bielman]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mattbie/2010/11/09/running-a-troubleshooter-from-the-command-line/</guid>
      <description><![CDATA[On TechNet you’ll find an article the describes the command line usage for a tool called the...]]></description>
      <content:encoded><![CDATA[<p>On TechNet you’ll find an article the describes the command line usage for a tool called the Microsoft Support Diagnostic Tool (MSDT.EXE), which you can use to launch a Windows Troubleshooting Pack from (obviously) the command line.&#160; The article has all the details, but I thought I’d take a moment today to give folks the short and sweet version.</p>  <p><strong>To run an inbox troubleshooter that ships with Windows 7 from the command line use this command</strong></p>  <blockquote>   <p>msdt.exe /id &lt;diagnostic_id&gt;</p> </blockquote>  <blockquote>   <p>Example: msdt.exe /id NetworkDiagnosticsWeb</p> </blockquote>  <p><strong>To run a custom-built troubleshooter stored locally use this command line</strong></p>  <blockquote>   <p>msdt.exe /path &lt;path_to_troubleshooter&gt;</p> </blockquote>  <blockquote>   <p>Example: msdt.exe /path c:\troubleshooters\myTroubleshooter</p> </blockquote>  <p><strong>or, if the troubleshooter is a .diagcab file</strong></p>  <blockquote>   <p>msdt.exe /cab &lt;path_to_diagcab&gt;</p> </blockquote>  <blockquote>   <p>Example: msdt.exe /cab c:\troubleshooters\myTroubleshooter.diagcab</p> </blockquote>  <p>Starting troubleshooters from the command line is <em>really</em> powerful when you combine it with your own experiences running on Windows 7.&#160; Application developers can take advantage of these troubleshooters to help their customers fix problems that may prevent them from getting the best possible experience.&#160; For example, and application which requires internet connectivity can invoke the Windows 7 Networking troubleshooter rather than presenting a error message that the network isn’t available.&#160; To accomplish this, all the developer needs to do is run the “msdt.exe /id NetworkDiagnosticsWeb” command line.&#160; The troubleshooter will take care of the rest.</p>  <p>Here is a short list of troubleshooter IDs to get you started, the rest can be found <a href="https://technet.microsoft.com/en-us/library/ee424379(WS.10).aspx">here</a>.</p>  <table border="1" cellspacing="0" cellpadding="2" width="478"><tbody>     <tr>       <td valign="top" width="200">         <blockquote style="margin-right: 0px" dir="ltr">           <p><strong>Troubleshooting Pack ID</strong></p>         </blockquote>       </td>        <td valign="top" width="276">         <blockquote style="margin-right: 0px" dir="ltr">           <p align="left"><strong>Description</strong></p>         </blockquote>       </td>     </tr>      <tr>       <td valign="top" width="200">DeviceDiagnostic</td>        <td valign="top" width="276">         <p>Troubleshoots problems using hardware and access devices connected to the computer.</p>       </td>     </tr>      <tr>       <td valign="top" width="200">NetworkDiagnosticsWeb</td>        <td valign="top" width="276">         <p>Troubleshoots problems connecting to the Internet or to a specific Web site.</p>       </td>     </tr>      <tr>       <td valign="top" width="200">AudioPlaybackDiagnostic</td>        <td valign="top" width="276">         <p>Troubleshoots problems playing sounds and other audio files.</p>       </td>     </tr>      <tr>       <td valign="top" width="200">PrinterDiagnostic</td>        <td valign="top" width="276">         <p>Troubleshoots problems printing.</p>       </td>     </tr>   </tbody></table>  <p>Enjoy!</p>  <p>-mb</p>]]></content:encoded>
    </item>
    <item>
      <title>Working with devices</title>
      <link>https://docs.microsoft.com/archive/blogs/mattbie/working-with-devices</link>
      <pubDate>Wed, 16 Jun 2010 09:49:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Bielman]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mattbie/2010/06/16/working-with-devices/</guid>
      <description><![CDATA[I talked to several folks at Tech Ed who wanted to know if it was possible to work with devices and...]]></description>
      <content:encoded><![CDATA[<p>I talked to several folks at Tech Ed who wanted to know if it was possible to work with devices and do something like an uninstall/reinstall using a Troubleshooting Pack.&nbsp; Yes, you absolutely can!&nbsp; In fact, there are two ways you can accomplish this, so I&rsquo;ll show you both.</p>
<h3>Method 1: Reuse the Windows &ldquo;Devices&rdquo; Troubleshooting Pack</h3>
<p>This is definitely the method I&rsquo;d recommend.&nbsp; It doesn&rsquo;t take a lot of effort and you can get really good results.&nbsp; Windows 7 includes a great devices troubleshooter that can do much more than just uninstall and reinstall devices, and you&rsquo;ll get all that extra goodness for free!&nbsp; Since it&rsquo;s included with Windows 7 you know it&rsquo;ll be there.&nbsp; All we need to do is tap into that workflow; let&rsquo;s look at how you can do that.</p>
<p>If you don&rsquo;t know which device is having problems you can just launch the device troubleshooter and it&rsquo;ll try to figure it out.&nbsp; Launching this Troubleshooting Pack from the command line is simple, just type the following command.&nbsp; This is identical to launching the Troubleshooting Pack from the Troubleshooting Control Panel.&nbsp; </p>
<blockquote>
<p><span style="font-family: Courier New;"><span style="font-size: small;"><span style="font-family: courier new,courier;">msdt.exe /id DeviceDiagnostic /skip true</span></span></span></p>
</blockquote>
<p>If there is a specific device that&rsquo;s causing you problems you can pass the PNPDeviceID for that device to the Troubleshooting Pack.&nbsp; To do this we must change the command line slightly.&nbsp; We&rsquo;ve added the &ldquo;/param&rdquo; command line argument so we can pass in the specific PNPDeviceID of the problem device.&nbsp; Obviously, you need to know the PNPDeviceID for the problem device for this to be useful.&nbsp; This is identical to right-clicking a device in Devices and Printers and selecting Troubleshoot.</p>
<blockquote>
<p><span style="font-family: Courier New;"><span style="font-size: small;">msdt.exe /id DeviceDiagnostic /param "IT_SelectDevice=[PNPDeviceID]" /skip true</span></span></p>
<p><span style="font-size: small;">Example: <br /></span><span style="font-family: Courier New;"><span style="font-size: small;">msdt.exe /id DeviceDiagnostic /param "IT_SelectDevice=PCI\VEN_8086&amp;DEV_27D8&amp;SUBSYS_380217AA&amp;REV_02\3&amp;21436425&amp;0&amp;D8" /skip true</span></span></p>
</blockquote>
<p>This is the best approach for general device issues.&nbsp; It&rsquo;ll enable devices that have been disabled, search for drivers, and address several other potential problems.&nbsp; </p>
<h3>Method 2: Build an Uninstall/Reinstall Troubleshooting Pack</h3>
<p>The second way to uninstall and reinstall a device is to build your own Troubleshooting Pack.&nbsp; This is more work but will give you complete control over the experience.&nbsp; </p>
<p>The trick here is that while PowerShell gives you tons of great tools to find devices and check for problems, it doesn&rsquo;t give you an obvious method to actually uninstall and reinstall the device.&nbsp; In an <a target="_blank" href="https://blogs.msdn.com/b/mattbie/archive/2010/02/23/how-to-call-net-and-win32-methods-from-powershell-and-your-troubleshooting-packs.aspx">earlier post</a> I showed you how to access Win32 APIs from PowerShell and that&rsquo;s exactly what we need here.&nbsp; Coincidentally, the Win32 part of that example already has the code we need to <em>reinstall</em> a device, so all we need is some code to <em>uninstall</em> the device.</p>
<p>Rather than just post the uninstall/reinstall code, I thought I&rsquo;d share with you a complete <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/34/86/Samples/2806.Uninstall_a_Device.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-34-86-Samples/2806.Uninstall_5F00_a_5F00_Device.zip">Troubleshooting Pack sample</a> that&rsquo;ll show you how to uninstall and reinstall a device.&nbsp; It enumerates all PCI devices and displays them in a list, so you can select the device to remove.&nbsp; You can also manually specify the PNPDeviceID of the device you want to work with.&nbsp; This sample requires the latest version of the Windows Troubleshooting Pack Designer, which you can download <a target="_blank" href="https://go.microsoft.com/fwlink/?LinkID=191420">here</a>.&nbsp; Unzip the sample into your &ldquo;Documents\Troubleshooting Packs&rdquo; folder and open it in the Troubleshooting Pack Designer.</p>
<p>So there you have it. Two ways to manage devices from within a Troubleshooting Pack.&nbsp; Pick the method that works best for your environment&nbsp; and end users.&nbsp; Drop me a comment if you find this useful or would like to see other examples.</p>
<p>-mb</p>]]></content:encoded>
    </item>
    <item>
      <title>Thank you Tech Ed 2010</title>
      <link>https://docs.microsoft.com/archive/blogs/mattbie/thank-you-tech-ed-2010</link>
      <pubDate>Sun, 13 Jun 2010 21:26:06 GMT</pubDate>
      <dc:creator><![CDATA[Matt Bielman]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mattbie/2010/06/13/thank-you-tech-ed-2010/</guid>
      <description><![CDATA[Tech Ed 2010 has come and gone.&#160; What an experience!&#160; Friday was a travel day for me,...]]></description>
      <content:encoded><![CDATA[<p>Tech Ed 2010 has come and gone.&#160; What an experience!&#160; Friday was a travel day for me, which I expect is the case for many of you.&#160; I’m writing this post from the the Dallas/Fort-Worth Airport at gate C20 waiting for my flight back to Seattle.&#160; </p>  <p>I’ve got an hour to kill, so I thought I’d take a moment to say thank you to everyone who attended Tech Ed 2010.&#160; I’d like to extend a special thank you to everyone that attended my Windows Troubleshooting Platform interactive session, swung by to chat about troubleshooting at the Windows Manageability booth, or flagged me down during the event.&#160; The interest shown towards the Windows Troubleshooting Platform surpassed all my expectations!&#160; </p>  <p>I got some great feedback from everyone and will be following up as best I can, but I didn’t get the opportunity to connect with everyone.&#160; Many of you were turned away from the session because it was full and believe me when I say that nobody was more surprised than I!&#160; Well, I want to keep that interest alive.&#160; For those of you that weren’t able attend I highly recommend viewing the “Building Troubleshooters” session I presented for the Windows Summit 2010.&#160; Registration is free and it’ll help bring you up to speed.&#160; Those of you that were able to attend may find it useful as well.&#160; It includes some more in-depth examples of how to use the Windows Troubleshooting Platform to reduce support costs.&#160; </p>  <p>If you have a question you weren’t able to ask during the event please feel free to drop me a line here on the MSDN blog and I’ll do my best to answer them.</p>  <p>Thanks everyone!</p>  <p>-mb</p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Troubleshooting Platform Quick Reference</title>
      <link>https://docs.microsoft.com/archive/blogs/mattbie/windows-troubleshooting-platform-quick-reference</link>
      <pubDate>Thu, 03 Jun 2010 17:15:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Bielman]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mattbie/2010/06/03/windows-troubleshooting-platform-quick-reference/</guid>
      <description><![CDATA[Hi Everyone, I&rsquo;ve created a handy quick reference for the CmdLets, interactions, and extension...]]></description>
      <content:encoded><![CDATA[<p>Hi Everyone, I&rsquo;ve created a handy quick reference for the CmdLets, interactions, and extension points provided by the Windows Troubleshooting Platform.&nbsp; I sometimes forget all the little nuances and have to go look up stuff on MSDN, but no longer.&nbsp; Just print this sheet out, tack it to your wall, and you&rsquo;ll always have Windows Troubleshooting Platform cheat sheet at the ready, just in case.</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/01/97/52/Windows%20Troubleshooting%20Platform%20Quick%20Reference.pdf" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-01-97-52/Windows-Troubleshooting-Platform-Quick-Reference.pdf">Windows Troubleshooting Platform Quick Reference.pdf</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Summit 2010</title>
      <link>https://docs.microsoft.com/archive/blogs/mattbie/windows-summit-2010</link>
      <pubDate>Wed, 02 Jun 2010 09:59:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Bielman]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mattbie/2010/06/02/windows-summit-2010/</guid>
      <description><![CDATA[Go check out all the awesome content available for System Builders, ISVs, and IHVs at the Windows...]]></description>
      <content:encoded><![CDATA[<p>Go check out all the awesome content available for System Builders, ISVs, and IHVs at the <a href="https://www.microsoft.com/windows/windows-summit/default.aspx">Windows Summit 2010</a>, including an introduction to how you can <a href="https://msdn.microsoft.com/en-au/windows/desktop/hh559177.aspx">use the Windows Troubleshooting Platform to save support costs</a>, presented by me!</p>
<p>-mb</p>]]></content:encoded>
    </item>
    <item>
      <title>Sample DxDiag Troubleshooting Pack</title>
      <link>https://docs.microsoft.com/archive/blogs/mattbie/sample-dxdiag-troubleshooting-pack</link>
      <pubDate>Fri, 28 May 2010 10:38:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Bielman]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mattbie/2010/05/28/sample-dxdiag-troubleshooting-pack/</guid>
      <description><![CDATA[One of the questions I&rsquo;m often asked is&nbsp;how to use existing tools with the Windows...]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal" style="MARGIN: 0in 0in 10pt"><span style="font-size: small;"><span style="font-family: Calibri;">One of the questions I&rsquo;m often asked is&nbsp;how to use existing tools with the Windows Troubleshooting Platform, and how to use the log files produced by those tools.&nbsp; I've built a simple demo that'll show you how to do this.&nbsp; This example runs DxDiag, interprets the log, and displays some next steps to the user. </span></span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 10pt"><span style="font-family: Calibri; font-size: small;">This sample is built using&nbsp;the latest version of the Windows Troubleshooting Pack Designer, which you can get by installing the <a href="https://go.microsoft.com/fwlink/?LinkID=191420">Windows 7 SDK version 7.1</a></span>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/01/70/07/DirectX_Troubleshooting_Pack.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-01-70-07/DirectX_5F00_Troubleshooting_5F00_Pack.zip">DirectX_Troubleshooting_Pack.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Troubleshooting Platform meta-pack example</title>
      <link>https://docs.microsoft.com/archive/blogs/mattbie/windows-troubleshooting-platform-meta-pack-example</link>
      <pubDate>Fri, 02 Apr 2010 17:10:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Bielman]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mattbie/2010/04/02/windows-troubleshooting-platform-meta-pack-example/</guid>
      <description><![CDATA[Today I thought I'd briefly touch on a new troubleshooting concept-- the meta-pack.&nbsp; A...]]></description>
      <content:encoded><![CDATA[<P>Today I thought I'd briefly touch on a new troubleshooting concept-- the meta-pack.&nbsp; A meta-pack is a logical grouping of multiple Windows Troubleshooting Packs which can then be executed as one.&nbsp; You can use a meta-pack to group similar troubleshooting tasks or to extend the functionality of an existing diagnostic without having to modify the original code.&nbsp; For example, rather than build a new troubleshooting pack that addresses basic networking plus your configuration-specific root-causes you can create a meta-pack that includes the Windows 7 networking troubleshooter plus your configurations-specific troubleshooter, giving you the basic network troubleshooting for free.</P>
<P>I've attached a sample DiagCab file that illustrates this concept by combining the Windows 7 maintenance, audio, printer, and aero troubleshooters into one meta-pack.&nbsp;&nbsp;&nbsp; </P>
<P>The contents of the DiagCab is quite simple.&nbsp; It contains one file called "metapack.diagcfg" which defines the meta-pack.&nbsp; The contents of the file is provided below.&nbsp; Transforming this file into a meta-pack is simply a matter of cabbing up the file and changing the extension from ".cab" to ".diagcab".&nbsp;</P>
<P>
<TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-COLLAPSE: collapse; BACKGROUND: #d9d9d9; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoTableGrid border=1 cellSpacing=0 cellPadding=0 class="MsoTableGrid">
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: black 1pt solid; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1" vAlign=top width=638>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">&lt;?xml version="1.0" encoding="utf-8"?&gt;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">&lt;PackageConfiguration xmlns="https://www.microsoft.com/schemas/dcm/configuration/2008"&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;Execution&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;Package Path="%windir%\diagnostics\scheduled\Maintenance"/&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;Package Path="%windir%\diagnostics\system\audio"/&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;Package Path="%windir%\diagnostics\system\printer"/&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;Package Path="%windir%\diagnostics\system\aero"/&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;/Execution&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">&lt;/PackageConfiguration&gt;</SPAN><o:p></o:p></P></TD></TR></TBODY></TABLE></P>
<P>If you wanted to extend a Windows 7 Troubleshooting Pack then the XML and directory structure would look something like this.&nbsp; Note that the first package entry points to a folder called "MyAppDiag"; this is the folder that contains your completed diagnostic, which must be included.&nbsp; Cab the whole thing up, rename to .diagcab, and you're ready to go!</P>
<P><STRONG>Contents of .DiagCfg</STRONG></P>
<TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-COLLAPSE: collapse; BACKGROUND: #d9d9d9; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoTableGrid border=1 cellSpacing=0 cellPadding=0 class="MsoTableGrid">
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: black 1pt solid; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1" vAlign=top width=638>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">&lt;?xml version="1.0" encoding="utf-8"?&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">&lt;PackageConfiguration xmlns="https://www.microsoft.com/schemas/dcm/configuration/2008"&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;Execution&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;Package Path="MyAppDiag"/&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;Package Path="%windir%\diagnostics\system\audio"/&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"><o:p></o:p></SPAN></P><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;/Execution&gt;<o:p></o:p></SPAN> 
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">&lt;/PackageConfiguration&gt;</SPAN><o:p></o:p></P></TD></TR></TBODY></TABLE>
<P><STRONG>Directory Structure of .DiagCab</STRONG></P>
<P>
<TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-COLLAPSE: collapse; BACKGROUND: #d9d9d9; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoTableGrid border=1 cellSpacing=0 cellPadding=0 class="MsoTableGrid">
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: black 1pt solid; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1" vAlign=top width=638>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">.\Metapack.diagcfg<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">.\MyAppDiag<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">.\MyAppDiag\DiagPackage.cat<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">.\MyAppDiag\MyAppDiag.diagpkg<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">.\MyAppDiag\*.ps1<o:p></o:p></SPAN></P></TD></TR></TBODY></TABLE></P>
<P>-mb</P>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/98/98/84/MetaPack.diagcab" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-98-98-84/MetaPack.diagcab">MetaPack.diagcab</a></p>]]></content:encoded>
    </item>
    <item>
      <title>How to call .NET and Win32 methods from PowerShell (and your troubleshooting packs)</title>
      <link>https://docs.microsoft.com/archive/blogs/mattbie/how-to-call-net-and-win32-methods-from-powershell-and-your-troubleshooting-packs</link>
      <pubDate>Tue, 23 Feb 2010 14:00:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Bielman]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mattbie/2010/02/23/how-to-call-net-and-win32-methods-from-powershell-and-your-troubleshooting-packs/</guid>
      <description><![CDATA[Every once in a while I run into a problem that I just don't know how to solve using PowerShell...]]></description>
      <content:encoded><![CDATA[<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Every once in a while I run into a problem that I just don't know how to solve using PowerShell directly.&nbsp; Fortunately, PowerShell has great interoperability with other .NET code, so if you're already familiar with VB.NET or C# you'll never be lost.&nbsp; <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">One of my "bad habits" is to use .NET methods instead of native PowerShell cmdlets.&nbsp; Even now I still find myself using [System.IO.File]::Exists() instead of Test-Path; it's just what pops into my head when I think about that task.&nbsp; I call this a bad habit because some of the folks I interact with aren't C# developers and don't intuitively understand what's going on when there is inline .NET calls all over the place.&nbsp; Here's an example of what I'm talking about.&nbsp; Both these functions do the same thing; depending on your background you may gravitate towards one or the other.&nbsp; Where possible, I recommend using the native PowerShell cmdlet as it'll help other PowerShell users understand what's going on.&nbsp; <o:p></o:p></SPAN></P>
<TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-COLLAPSE: collapse; BACKGROUND: #d9d9d9; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoTableGrid border=1 cellSpacing=0 cellPadding=0 class="MsoTableGrid">
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.15in; PADDING-RIGHT: 5.4pt; BORDER-TOP: black 1pt solid; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1" vAlign=top width=590>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"># Native PowerShell version<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes">if</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"> ((<SPAN style="COLOR: blue">test-path</SPAN> c:\windows\notepad.exe) <SPAN style="COLOR: #2b91af">-eq</SPAN> $true)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green"># do something interesting<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>$PSFileInfo = <SPAN style="COLOR: blue">Get-ItemProperty</SPAN> c:\windows\notepad.exe<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>echo <SPAN style="COLOR: #a31515">"PSFileInfo"<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>$PSFileInfo<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes">}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"># .NET Version<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes">if</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"> ([System.IO.File]::Exists(<SPAN style="COLOR: #a31515">"C:\windows\notepad.exe"</SPAN>) <SPAN style="COLOR: #2b91af">-eq</SPAN> $true)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green"># do something interesting<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>$NETFileInfo = <SPAN style="COLOR: blue">New-Object</SPAN> System.IO.FileInfo <SPAN style="COLOR: #2b91af">-ArgumentList</SPAN> <SPAN style="COLOR: #a31515">"C:\windows\notepad.exe"<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>echo <SPAN style="COLOR: #a31515">"NETFileInfo"<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>$NETFileInfo<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes">}<o:p></o:p></SPAN></P></TD></TR></TBODY></TABLE>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">This style of inline .NET call is pretty convenient when you only need one or two static methods, but what about something more complex?&nbsp; What if you need to call a Win32 API?&nbsp; Well, you're in luck, because PowerShell provides a method to get you on your way.&nbsp; You can use the PowerShell SDK to build a custom cmdlet, but is there another way?&nbsp; Yes, there is!&nbsp; <o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Let's say that you're building a Windows Troubleshooting Pack that's designed to resolve problems with your device.&nbsp; One of the manual troubleshooting steps you're likely to perform is to check the device in Device Manager for errors, then uninstall and reinstall the device.&nbsp; In order to do this in your troubleshooter you need to be able to:<o:p></o:p></SPAN></P>
<OL type=1>
<LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l1 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Identify the device<o:p></o:p></SPAN></LI>
<LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l1 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Get its state (ConfigManagerErrorCode for those familiar with accessing devices using WMI)<o:p></o:p></SPAN></LI>
<LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l1 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Uninstall the device<o:p></o:p></SPAN></LI>
<LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l1 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Reinstall the device<o:p></o:p></SPAN></LI></OL>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">In most cases you'll be able to do the first two tasks directly from PowerShell by using WMI.&nbsp; Uninstalling and reinstalling the device is a bit more complicated, you'll need to call some Win32 APIs to get that done.&nbsp; So let's take a look at how that works in PowerShell and the Windows Troubleshooting Platform.&nbsp; Conceptually, the process looks like this:<o:p></o:p></SPAN></P>
<OL type=1>
<LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l2 level1 lfo2; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Identify the Win32 APIs you need to perform this task<o:p></o:p></SPAN></LI>
<LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l2 level1 lfo2; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Create a C#/VB.NET class that wraps the Win32 APIs<o:p></o:p></SPAN></LI>
<LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l2 level1 lfo2; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Bring your wrapper class into PowerShell<o:p></o:p></SPAN></LI>
<LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l2 level1 lfo2; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Call the methods defined in your wrapper class from PowerShell<o:p></o:p></SPAN></LI></OL>
<TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-COLLAPSE: collapse; BACKGROUND: #d9d9d9; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoTableGrid border=1 cellSpacing=0 cellPadding=0 class="MsoTableGrid">
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: black 1pt solid; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1" vAlign=top width=638>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Best Practice: </SPAN></B><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">While you can&nbsp;do all the steps in this example&nbsp;in&nbsp;Notepad&nbsp;or the PowerShell ISE,&nbsp;I strongly recommend using Visual Studio to create your C#/VB.NET class when doing this for real.&nbsp; Visual Studio will give you access to IntelliSense and all sorts of other features that'll make your life easier.&nbsp; If you don't have Visual Studio you can download the Express edition of your favorite language for <A href="https://www.microsoft.com/express/">free</A>.<B style="mso-bidi-font-weight: normal"><o:p></o:p></B></SPAN></P></TD></TR></TBODY></TABLE>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">I'm going to skip the uninstall step and focus on the reinstall.&nbsp; The concept related to accessing Win32 APIs is identical, but uninstall requires us to do steps one and two first.&nbsp; For the purposes of this example we can manually do steps 1-3 and&nbsp;code only the reinstall.&nbsp; <o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; mso-bidi-font-size: 10.0pt; mso-fareast-font-family: 'Times New Roman'"><FONT size=3>Step 1: Identify the Win32 APIs you need to perform this task<o:p></o:p></FONT></SPAN></B></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">MSDN is your friend here.&nbsp; In this case we need 3 Win32 APIs:<o:p></o:p></SPAN></P>
<OL type=1>
<LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l0 level1 lfo3; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'"><A href="https://msdn.microsoft.com/en-us/library/ms790835.aspx">CM_Locate_DevNode_Ex</A><o:p></o:p></SPAN></LI>
<LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l0 level1 lfo3; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'"><A href="https://msdn.microsoft.com/en-us/library/ms790794.aspx">CM_Reenumerate_DevNode_Ex</A><o:p></o:p></SPAN></LI>
<LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l0 level1 lfo3; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'"><A href="https://msdn.microsoft.com/en-us/library/ms789525.aspx">CMP_WaitNoPendingInstallEvents</A><o:p></o:p></SPAN></LI></OL>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; mso-bidi-font-size: 10.0pt; mso-fareast-font-family: 'Times New Roman'"><FONT size=3>Step 2: Create a C#/VB.NET class that wraps the Win32 APIs<o:p></o:p></FONT></SPAN></B></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">This is where you'll spend most of your time and why I'd recommend doing this work inside Visual Studio where you have great debugging tools.&nbsp; To save time I've included the entire wrapper source below in C#.&nbsp; Paste this into Visual Studio, save, and do a quick build to make sure there aren't any errors.<o:p></o:p></SPAN></P>
<TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-COLLAPSE: collapse; BACKGROUND: #d9d9d9; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoTableGrid border=1 cellSpacing=0 cellPadding=0 class="MsoTableGrid">
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.15in; PADDING-RIGHT: 5.4pt; BORDER-TOP: black 1pt solid; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1" vAlign=top width=590>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes">using</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"> System.Runtime.InteropServices;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes">using</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"> System;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes">namespace</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"> mattbie.examples.devices<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">// These are the native win32 methods that we require<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">internal</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">NativeMethods<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[<SPAN style="COLOR: #2b91af">DllImport</SPAN>(<SPAN style="COLOR: #a31515">"cfgmgr32.dll"</SPAN>, SetLastError = <SPAN style="COLOR: blue">true</SPAN>, EntryPoint = <SPAN style="COLOR: #a31515">"CM_Locate_DevNode_Ex"</SPAN>, CharSet = <SPAN style="COLOR: #2b91af">CharSet</SPAN>.Auto)]<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">extern</SPAN> <SPAN style="COLOR: #2b91af">UInt32</SPAN> CM_Locate_DevNode_Ex(<SPAN style="COLOR: blue">ref</SPAN> <SPAN style="COLOR: #2b91af">UInt32</SPAN> DevInst, <SPAN style="COLOR: #2b91af">IntPtr</SPAN> DeviceID, <SPAN style="COLOR: #2b91af">UInt64</SPAN> Flags, <SPAN style="COLOR: #2b91af">IntPtr</SPAN> Machine);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[<SPAN style="COLOR: #2b91af">DllImport</SPAN>(<SPAN style="COLOR: #a31515">"cfgmgr32.dll"</SPAN>, SetLastError = <SPAN style="COLOR: blue">true</SPAN>, EntryPoint = <SPAN style="COLOR: #a31515">"CM_Reenumerate_DevNode_Ex"</SPAN>, CharSet = <SPAN style="COLOR: #2b91af">CharSet</SPAN>.Auto)]<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">extern</SPAN> <SPAN style="COLOR: #2b91af">UInt32</SPAN> CM_Reenumerate_DevNode_Ex(<SPAN style="COLOR: #2b91af">UInt32</SPAN> DevInst, <SPAN style="COLOR: #2b91af">UInt64</SPAN> Flags, <SPAN style="COLOR: #2b91af">IntPtr</SPAN> Machine);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[<SPAN style="COLOR: #2b91af">DllImport</SPAN>(<SPAN style="COLOR: #a31515">"cfgmgr32.dll"</SPAN>, SetLastError = <SPAN style="COLOR: blue">true</SPAN>, EntryPoint = <SPAN style="COLOR: #a31515">"CMP_WaitNoPendingInstallEvents"</SPAN>, CharSet = <SPAN style="COLOR: #2b91af">CharSet</SPAN>.Auto)]<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">extern</SPAN> <SPAN style="COLOR: #2b91af">UInt32</SPAN> CMP_WaitNoPendingInstallEvents(<SPAN style="COLOR: #2b91af">UInt32</SPAN> TimeOut);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">// This class houses the public methods that we'll use from powershell<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">StaticMethods<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt32</SPAN> CR_SUCCESS = 0;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt64</SPAN> CM_REENUMERATE_SYNCHRONOUS = 1;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt64</SPAN> CM_LOCATE_DEVNODE_NORMAL = 0;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: #2b91af">UInt32</SPAN> RescanAllDevices()<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//only connect to local device nodes<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">UInt32</SPAN> ResultCode = 0;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">IntPtr</SPAN> LocalMachineInstance = <SPAN style="COLOR: #2b91af">IntPtr</SPAN>.Zero;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">UInt32</SPAN> DeviceInstance = 0;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">UInt32</SPAN> PendingTime = 30000;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>ResultCode = <SPAN style="COLOR: #2b91af">NativeMethods</SPAN>.CM_Locate_DevNode_Ex(<SPAN style="COLOR: blue">ref</SPAN> DeviceInstance, <SPAN style="COLOR: #2b91af">IntPtr</SPAN>.Zero, CM_LOCATE_DEVNODE_NORMAL, LocalMachineInstance);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (CR_SUCCESS == ResultCode)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>ResultCode = <SPAN style="COLOR: #2b91af">NativeMethods</SPAN>.CM_Reenumerate_DevNode_Ex(DeviceInstance, CM_REENUMERATE_SYNCHRONOUS, LocalMachineInstance);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>ResultCode = <SPAN style="COLOR: #2b91af">NativeMethods</SPAN>.CMP_WaitNoPendingInstallEvents(PendingTime);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> ResultCode;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-no-proof: yes">}</SPAN><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-size: 10.0pt; mso-fareast-font-family: 'Times New Roman'"><o:p></o:p></SPAN></P></TD></TR></TBODY></TABLE>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt 0.5in; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; mso-bidi-font-size: 10.0pt; mso-fareast-font-family: 'Times New Roman'"><FONT size=3>Step 3: Bring your wrapper class into PowerShell<o:p></o:p></FONT></SPAN></B></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Now it's time to get our wrapper into PowerShell.&nbsp; You have a few options here; include as an assembly, or include as source; your scenario and business needs may lend itself to one method more than the other.&nbsp; For this example we're going to include our wrapper as source.&nbsp; Obviously, including our wrapper as source code means that it’s readable by anyone who opens the PowerShell script in a text editor.&nbsp; Including as source works particularly well for short snippets like this.&nbsp; Regardless of the method, you'll be using the Add-Type cmdlet, which will do all the heavy lifting for us.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">I've created a new function in my PowerShell script called InitDeviceClass that'll bring our wrapper into play.&nbsp; You can see this function in the completed PowerShell script at the end of this post, it looks complicated, but in reality it only has two statements.&nbsp; The first statement defines a string variable named $SourceCode which contains the entire source for our wrapper.&nbsp; Just copy/paste the whole source from Visual Studio into the PowerShell ISE.&nbsp; The second statement does all the work, so let's take a closer look at that.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Add-Type -TypeDefinition $SourceCode<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Add-Type is a new cmdlet introduce with PowerShell 2.0 that lets you define a .NET Framework class in your Windows PowerShell session.&nbsp; For a complete description check out the MSDN reference.&nbsp; The -TypeDefinition&nbsp;parameter&nbsp;is where we tell Add-Type how to find the type definition that we want to add.&nbsp; In this case, we're just passing it the entire C# source file, which it'll compile and make available to us.&nbsp; If your C# has errors in it, Add-Type will return an error letting you know that there were compile-time errors with your code.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">That's it.&nbsp; The wrapper is now loaded and ready to use, so let's see how that works.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; mso-bidi-font-size: 10.0pt; mso-fareast-font-family: 'Times New Roman'"><FONT size=3>Step 4: Call the methods defined in your wrapper class from PowerShell<o:p></o:p></FONT></SPAN></B></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">Our wrapper defines one public static method, which makes things pretty easy.&nbsp; All we need to do is call our init function and then the wrapper is ready to use.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The syntax is exactly the same as my old [System.IO.File]::Exists() crutch.<o:p></o:p></SPAN></P>
<TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-COLLAPSE: collapse; BACKGROUND: #d9d9d9; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoTableGrid border=1 cellSpacing=0 cellPadding=0 class="MsoTableGrid">
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: black 1pt solid; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1" vAlign=top width=638>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes">InitDevice Class<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes">[mattbie.examples.devices.staticmethods]::RescanAllDevices()</SPAN><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'"><o:p></o:p></SPAN></P></TD></TR></TBODY></TABLE>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">And there you have it.&nbsp; Win32, wrapped in .NET, then wrapped in PowerShell, ready to be added to your Troubleshooting Pack resolver script.&nbsp; Here is the complete PowerShell script.&nbsp; Enjoy!<o:p></o:p></SPAN></P>
<TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-COLLAPSE: collapse; BACKGROUND: #d9d9d9; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoTableGrid border=1 cellSpacing=0 cellPadding=0 class="MsoTableGrid">
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 6.65in; PADDING-RIGHT: 5.4pt; BORDER-TOP: black 1pt solid; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1" vAlign=top width=638>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes"># Resolver Script - This script fixes the root cause. It only runs if the Troubleshooter detects the root cause.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes"># Key cmdlets: <o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes"># -- get-diaginput invokes an interactions and returns the response<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes"># -- write-diagprogress displays a progress string to the user<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes"># Your logic to fix the root cause here<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes"># Create a function that loads our managed code into powershell<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes">function InitDeviceClass<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green"># This is the C# source code.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I've tested this in visual studio and then copy/pasted it here<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green"># You could also load the .CS file from the disk, if you prefer<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>[string]$SourceCode =<SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: #943634; mso-themecolor: accent2; mso-themeshade: 191">@"<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>using System.Runtime.InteropServices;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>using System;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>namespace mattbie.examples.devices<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>// These are the native win32 methods that we require<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>internal static class NativeMethods<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[DllImport("cfgmgr32.dll", SetLastError = true, EntryPoint = "CM_Locate_DevNode_Ex", CharSet = CharSet.Auto)]<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>public static extern UInt32 CM_Locate_DevNode_Ex(ref UInt32 DevInst, IntPtr DeviceID, UInt64 Flags, IntPtr Machine);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[DllImport("cfgmgr32.dll", SetLastError = true, EntryPoint = "CM_Reenumerate_DevNode_Ex", CharSet = CharSet.Auto)]<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>public static extern UInt32 CM_Reenumerate_DevNode_Ex(UInt32 DevInst, UInt64 Flags, IntPtr Machine);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[DllImport("cfgmgr32.dll", SetLastError = true, EntryPoint = "CMP_WaitNoPendingInstallEvents", CharSet = CharSet.Auto)]<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>public static extern UInt32 CMP_WaitNoPendingInstallEvents(UInt32 TimeOut);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>// This class houses the public methods that we'll use from powershell<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>public static class StaticMethods<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>public const UInt32 CR_SUCCESS = 0;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>public const UInt64 CM_REENUMERATE_SYNCHRONOUS = 1;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>public const UInt64 CM_LOCATE_DEVNODE_NORMAL = 0;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>public static UInt32 RescanAllDevices()<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>//only connect to local device nodes<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>UInt32 ResultCode = 0;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>IntPtr LocalMachineInstance = IntPtr.Zero;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>UInt32 DeviceInstance = 0;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>UInt32 PendingTime = 30000;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>ResultCode = NativeMethods.CM_Locate_DevNode_Ex(ref DeviceInstance, IntPtr.Zero, CM_LOCATE_DEVNODE_NORMAL, LocalMachineInstance);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>if (CR_SUCCESS == ResultCode)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>ResultCode = NativeMethods.CM_Reenumerate_DevNode_Ex(DeviceInstance, CM_REENUMERATE_SYNCHRONOUS, LocalMachineInstance);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>ResultCode = NativeMethods.CMP_WaitNoPendingInstallEvents(PendingTime);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>return ResultCode;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 8pt; mso-themecolor: accent2; mso-themeshade: 191; mso-no-proof: yes">"@</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green"># use the powershell 2.0 add-type cmdlet to compile the source and make it available to our powershell session<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">add-type</SPAN> <SPAN style="COLOR: #2b91af">-TypeDefinition</SPAN> $SourceCode<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes">}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes"># Load up our C# code<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes">InitDeviceClass<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes"># Call the RescanAllDevices method<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes">[mattbie.examples.devices.staticmethods]::RescanAllDevices()<o:p></o:p></SPAN></P></TD></TR></TBODY></TABLE>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'">-MB<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>]]></content:encoded>
    </item>
    <item>
      <title>Change the troubleshooting experience to meet your needs</title>
      <link>https://docs.microsoft.com/archive/blogs/mattbie/change-the-troubleshooting-experience-to-meet-your-needs</link>
      <pubDate>Wed, 17 Feb 2010 15:16:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Bielman]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mattbie/2010/02/17/change-the-troubleshooting-experience-to-meet-your-needs/</guid>
      <description><![CDATA[If you use any of the inbox diagnostics on Windows 7 you'll notice that they're designed to find and...]]></description>
      <content:encoded><![CDATA[<P>If you use any of the inbox diagnostics on Windows 7 you'll notice that they're designed to find and fix a series of problems, but if you look at the maintenance diagnostic you'll see it sets a slightly different tone.&nbsp; Rather than address traditional "problems" it takes care of some common maintenance tasks, which doesn't fit with most of the messaging in the UI.&nbsp; By default, the final messaging assumes that you're addressing a break/fix problem and will show the customer text like this.</P>
<P>"The troubleshooter made some changes to your system.&nbsp; Try attempting the task you were trying to do before."</P>
<P>If you're building a diagnostic that is more like the maintenance troubleshooter that's task-driven rather than problem-driven&nbsp;and would like to change the messaging, you can.&nbsp; Add the &lt;Maintenance/&gt; extension point to your troubleshooting pack and the messaging will become a bit more generic.&nbsp; Here's a comparison of the two options.&nbsp; Take a look at the maintenance package in %windir%\diagnostics\scheduled\maintenance\DiagPackage.diagpkg for a complete example.</P>
<P mce_keep="true"><IMG style="WIDTH: 449px; HEIGHT: 205px" src="https://blogs.msdn.com/mattbie/attachment/9965413.ashx" width=173 height=131 mce_src="https://blogs.msdn.com/mattbie/attachment/9965413.ashx"></P>
<P mce_keep="true">-MB</P>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/96/54/13/Comparison.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-96-54-13/Comparison.jpg">Comparison.jpg</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Gaming with the Windows Troubleshooting Platform</title>
      <link>https://docs.microsoft.com/archive/blogs/mattbie/gaming-with-the-windows-troubleshooting-platform</link>
      <pubDate>Mon, 15 Feb 2010 09:20:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Bielman]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mattbie/2010/02/15/gaming-with-the-windows-troubleshooting-platform/</guid>
      <description><![CDATA[Today we’re going to dive straight into a fun, simple project; creating a multiple choice trivia...]]></description>
      <content:encoded><![CDATA[<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Today we’re going to dive straight into a fun, simple project; creating a multiple choice trivia style game using the Windows Troubleshooting Platform.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>We’re skipping the architecture, applicability, and design discussions; instead we’ll build this simple game that’ll run in our troubleshooting pack.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Let’s get to it!<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Before we get started, let’s go thru the list of things you’ll need.</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo1" class=MsoListParagraphCxSpFirst><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>1.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>A computer running Windows 7</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo1" class=MsoListParagraphCxSpMiddle><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>2.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>Basic understanding of PowerShell</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l1 level1 lfo1" class=MsoListParagraphCxSpLast><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>3.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>Windows 7 SDK</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>The first step is to install the tools that we’ll use to build your troubleshooting pack.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>These tools are included in the Windows 7 SDK, which is available </FONT><A href="https://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505" mce_href="https://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505"><FONT size=3 face=Calibri>here</FONT></A><FONT size=3 face=Calibri>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If you’re only interested in building troubleshooting packs you don’t need to install the entire SDK, you only need to install the “Win32 Development Tools”</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Now let’s get into the tool and start building a troubleshooting pack.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Launch the Windows Troubleshooting Pack Designer.</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo2" class=MsoListParagraphCxSpFirst><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>1.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>Start</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo2" class=MsoListParagraphCxSpMiddle><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>2.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>All Programs</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo2" class=MsoListParagraphCxSpMiddle><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>3.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>Microsoft Windows SDK v7.0</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo2" class=MsoListParagraphCxSpMiddle><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>4.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>Tools</FONT></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l2 level1 lfo2" class=MsoListParagraphCxSpLast><SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><SPAN style="mso-list: Ignore"><FONT size=3 face=Calibri>5.</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3 face=Calibri>Windows Troubleshooting Pack Designer</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Remember, we’re building a game, which isn’t the most appropriate use of this technology, but whatever.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>We’re going to build a simple question and answer game.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Select New from the Project menu to create the troubleshooting pack.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Call this pack “Guess” then click create.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Now we get to define what our troubleshooter will look like.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>On this first screen we can see the project name, description, and privacy URL, all of which will be displayed on the first screen of the troubleshooter.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Add a description to your troubleshooter and enter in a URL for the privacy link (this can be any URL for now). </FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Next we need to add a “Root Cause”.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In a real troubleshooter the root cause is a specific problem that you’re trying to fix, like “service x is stopped”.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For our guessing game, we’ll make a root cause for when the player guesses incorrectly.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Click “Add New Root Cause”, enter the following values, and then click next.</FONT></P>
<UL>
<LI>
<DIV style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Root Cause ID: GuessIsWrong</FONT></DIV></LI>
<LI>
<DIV style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Root Cause Name: Oops!&nbsp; You've guessed wrong!</FONT></DIV></LI>
<LI>
<DIV style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Root Cause Description: The answer you selected was incorrect.</FONT></DIV></LI></UL>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT face=Calibri><FONT size=3>The next screen will ask us a little bit more about this root cause.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Does the user need to be elevated to detect the problem?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Does the user need to answer any questions?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>We don’t need elevation, but we do need the user to answer questions, so check Yes under Interactions.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Notice that when you select yes a new list of interactions appears.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>We’ll define the questions for our game here.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Click the Add Interaction button.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>The Interaction Designer needs to know which type of question we want to ask.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>We’re going to limit our game to single answers of a multiple choice question, so select the single response type.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Next you’ll need to define the specifics for this interaction.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Enter the following values.</FONT></P>
<UL>
<LI>
<DIV style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Interaction ID: Question_01</FONT></DIV></LI>
<LI>
<DIV style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Question or Prompt: In what year was Microsoft founded?</FONT></DIV></LI>
<LI>
<DIV style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Explanation: Please select an answer from the list of choices below.</FONT></DIV></LI></UL>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Now we need to add some answers.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Scroll down to the Choice List, click Add Choice, and enter the details for each answer.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The title and description fields will be shown to the player; the value field will be used by our PowerShell script to determine which answer was selected.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Add the choices listed below, and then click OK.</FONT></P>
<TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-COLLAPSE: collapse; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt" class=MsoTableGrid border=1 cellSpacing=0 cellPadding=0 class="MsoTableGrid">
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes">
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 0.7in; PADDING-RIGHT: 5.4pt; BORDER-TOP: black 1pt solid; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1" vAlign=top width=67>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>Title<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT></B></P></TD>
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 99pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: black 1pt solid; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1" vAlign=top width=132>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>Description<o:p></o:p></FONT></FONT></B></P></TD>
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 63pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: black 1pt solid; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1" vAlign=top width=84>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face=Calibri>Value<o:p></o:p></FONT></FONT></B></P></TD></TR>
<TR style="mso-yfti-irow: 1">
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 0.7in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1" vAlign=top width=67>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><FONT size=3><FONT face=Calibri>1970<o:p></o:p></FONT></FONT></P></TD>
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 99pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; mso-border-bottom-themecolor: text1; mso-border-right-themecolor: text1" vAlign=top width=132>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P></TD>
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 63pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; mso-border-bottom-themecolor: text1; mso-border-right-themecolor: text1" vAlign=top width=84>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><FONT size=3><FONT face=Calibri>0<o:p></o:p></FONT></FONT></P></TD></TR>
<TR style="mso-yfti-irow: 2">
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 0.7in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1" vAlign=top width=67>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><FONT size=3><FONT face=Calibri>1975<o:p></o:p></FONT></FONT></P></TD>
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 99pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; mso-border-bottom-themecolor: text1; mso-border-right-themecolor: text1" vAlign=top width=132>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P></TD>
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 63pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; mso-border-bottom-themecolor: text1; mso-border-right-themecolor: text1" vAlign=top width=84>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><FONT size=3><FONT face=Calibri>1<o:p></o:p></FONT></FONT></P></TD></TR>
<TR style="mso-yfti-irow: 3">
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 0.7in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1" vAlign=top width=67>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><FONT size=3><FONT face=Calibri>1977<o:p></o:p></FONT></FONT></P></TD>
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 99pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; mso-border-bottom-themecolor: text1; mso-border-right-themecolor: text1" vAlign=top width=132>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P></TD>
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 63pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; mso-border-bottom-themecolor: text1; mso-border-right-themecolor: text1" vAlign=top width=84>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><FONT size=3><FONT face=Calibri>2<o:p></o:p></FONT></FONT></P></TD></TR>
<TR style="mso-yfti-irow: 4; mso-yfti-lastrow: yes">
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 0.7in; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1" vAlign=top width=67>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><FONT size=3><FONT face=Calibri>1980<o:p></o:p></FONT></FONT></P></TD>
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 99pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; mso-border-bottom-themecolor: text1; mso-border-right-themecolor: text1" vAlign=top width=132>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P></TD>
<TD style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt; WIDTH: 63pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: black 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; mso-border-bottom-themecolor: text1; mso-border-right-themecolor: text1" vAlign=top width=84>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><FONT size=3><FONT face=Calibri>3<o:p></o:p></FONT></FONT></P></TD></TR></TBODY></TABLE>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri></FONT>&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Each root cause that you define needs a resolver.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This is the action that should be taken when the root cause is detected.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In our case, we want to educate the player if they choose the wrong answer.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Click Add Resolver and fill out the fields as follows.</FONT></P>
<UL>
<LI>
<DIV style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Resolver Name: Show the history of Microsoft</FONT></DIV></LI>
<LI>
<DIV style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Resolver Description: Display "The History of Microsoft" video series on Channel 9</FONT></DIV></LI>
<LI>
<DIV style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Prompt the User: Yes</FONT></DIV></LI>
<LI>
<DIV style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Elevation: No</FONT></DIV></LI>
<LI>
<DIV style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>Interactions: No</FONT></DIV></LI></UL>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>Finally, we must define if the fix can be verified.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For the purposes of our game we won’t ask the player the same question again.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Click Define Verifier, select no under verifiable then click next.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>Now you’re ready to save and run your troubleshooting pack.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Click save, then select run from the build menu.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>First you’ll be asked to install a test certificate for testing, click OK to continue.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If you skip this step your troubleshooting pack won’t work!<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>At this point your troubleshooter doesn’t do much, but that’s about to change.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Notice that when you ran the troubleshooter it found the “Oops! You’ve guessed wrong!” problem.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Let’s go change this so that it’s based on the answer to our question.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Click on the Scripts node in the troubleshooting pack designer, then click edit troubleshooter script.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This will open the PowerShell editor and display your troubleshooting script.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>You’ll notice that by default is just passes true to the update-diagrootcause cmdlet, which tells the troubleshooter if the problem was found.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>First thing we need to do is show the player the question and get the answer.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This is pretty simple; all we need to do is call the get-diaginput cmdlet, pass it the id of our question, and get the result.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This is what that looks like in PowerShell</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><SPAN style="FONT-FAMILY: Courier"><SPAN style="COLOR: #7030a0"></SPAN><o:p><FONT size=2><FONT face="Courier New"><FONT color=#76923c>#Ask the customer a question<BR></FONT><SPAN style="COLOR: red">$Answer</SPAN> = <SPAN style="COLOR: blue">Get-DiagInput</SPAN> –id </FONT></FONT><SPAN style="COLOR: #7030a0"><FONT size=2 face="Courier New">Question_01</FONT></SPAN></o:p></SPAN></FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><SPAN style="FONT-FAMILY: Courier"><o:p><SPAN style="COLOR: #7030a0"></SPAN></o:p></SPAN></FONT><FONT size=3><FONT face=Calibri>The answer variable will contain the value, not the text, for the selected answer.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Next we need to determine if the answer is correct.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In this case, the correct answer is “1975”, which has a value of 1. This is the value that we entered for this item in the choice list.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Checking for the correct answer is now pretty simple; if the answer is 1 then they answered correctly, otherwise it’s incorrect.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Here is the completed PowerShell for our troubleshooter.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Notice that I’ve also changed $RootCauseDetected to set the problem (“Oops! You’ve guessed wrong!”) to be true only if the answer is incorrect.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P><FONT face=Calibri><SPAN style="mso-spacerun: yes">
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">$RootCauseID</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: #76923c; FONT-SIZE: 9pt; mso-themecolor: accent3; mso-themeshade: 191; mso-bidi-font-size: 11.0pt"> </SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">=<SPAN style="COLOR: #76923c; mso-themecolor: accent3; mso-themeshade: 191"> </SPAN><SPAN style="COLOR: #943634; mso-themecolor: accent2; mso-themeshade: 191">“GuessIsWrong”</SPAN><SPAN style="COLOR: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><BR><BR>#Ask the customer a question<BR></SPAN><SPAN style="COLOR: red">$Answer</SPAN> = <SPAN style="COLOR: blue">Get-DiagInput</SPAN> –id <SPAN style="COLOR: #7030a0">Question_01<BR><BR></SPAN><SPAN style="COLOR: #76923c; mso-themecolor: accent3; mso-themeshade: 191">#Check the answer<BR></SPAN>if (<SPAN style="COLOR: red">$Answer</SPAN> –eq 1)<BR>{<BR><SPAN style="COLOR: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>#Question answered incorrectly<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: red">$RootcauseDetected</SPAN> = <SPAN style="COLOR: red">$False</SPAN><BR>}<BR>else<BR>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: #76923c; FONT-SIZE: 9pt; mso-themecolor: accent3; mso-themeshade: 191; mso-bidi-font-size: 11.0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>#Question answered correctly<BR></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: red">$RootcauseDetected</SPAN> = <SPAN style="COLOR: red">$True</SPAN><BR>}<BR><BR><SPAN style="COLOR: #76923c; mso-themecolor: accent3; mso-themeshade: 191">#The following line notifies Windows Troubleshooting Platform of the status of this root cause</SPAN><BR><SPAN style="COLOR: blue">update-diagrootcause</SPAN> –id <SPAN style="COLOR: red">$RootCauseId</SPAN> –detected <SPAN style="COLOR: red">$RootCauseDetected</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal></SPAN></FONT><FONT size=3><FONT face=Calibri>Save your PowerShell script, switch back to the troubleshooting pack designer, and hit run.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Now the player has a question to answer!<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Run thru it a few times picking different answers to see how the rest of the experience changes.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3><FONT face=Calibri>Now it’s time to set up our resolver.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Click on the scripts node again, then click edit resolver script.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>By default, your resolver script is empty.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>We want to display the “History of Microsoft” web page if they user answers incorrectly.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>To do this, add the following line to your PowerShell script.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-size: 11.0pt; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">explorer.exe</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 9pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-size: 11.0pt; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"> </SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: #943634; FONT-SIZE: 9pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-themecolor: accent2; mso-themeshade: 191; mso-bidi-font-size: 11.0pt; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">“https://channel9.msdn.com/shows/History”</SPAN></FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>That’s it.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Save your script and run your troubleshooter.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Now when the player answers incorrectly they’ll be taken to the site.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Our game is complete!<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This is a very simple example, but you’ve used most of the elements that you’d need to build a full-fledged troubleshooter.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>You’ve asked the customer for input, evaluated their answer, and taken an action when the “problem” was detected.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>We could flesh out this game a bit more by adding more questions, keeping score, loading questions from a file, etc.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>All of this is possible within the windows troubleshooting pack framework.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>You can even create your own text-based adventure game as a troubleshooting pack; maybe I’ll cover that in a later example…</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>It’s not the intended purpose of the platform, but it’s good for a laugh.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Enjoy!</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=3 face=Calibri>-MB</FONT></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>]]></content:encoded>
    </item>
  </channel>
</rss>