<?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>Adam Semel's Developer Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/adam/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/adam/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 16 Apr 2019 04:27:37 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>How to “TOTALLY” customize your Home Realm Discovery Page in Windows Server 2012 R2 ADFS</title>
      <link>https://docs.microsoft.com/archive/blogs/adam/how-to-totally-customize-your-home-realm-discovery-page-in-windows-server-2012-r2-adfs</link>
      <pubDate>Fri, 13 Feb 2015 07:31:00 GMT</pubDate>
      <dc:creator><![CDATA[Bambam9876]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/adam/2015/02/13/how-to-totally-customize-your-home-realm-discovery-page-in-windows-server-2012-r2-adfs/</guid>
      <description><![CDATA[When using the latest version of ADFS, Windows Server 2012 R2 ADFS, if you have multiple identity...]]></description>
      <content:encoded><![CDATA[<p>When using the latest version of ADFS, Windows Server 2012 R2 ADFS, if you have multiple identity providers configured, ADFS will display its Home Realm Discovery (HRD) page. It has too; it has to ask you which provider you want to use to login with? The page is fine.. However it&rsquo;s not <em>fitting</em> in with my app scheme, and there are parts I don&rsquo;t want, for example.. I don&rsquo;t want the option to select the local AD as a provider. Here&rsquo;s a look at the default page (though showing just one provider):</p>
<p>&nbsp;</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/87/03/3312.blue.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-87-03/3312.blue.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/87/03/3312.blue.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-87-03/3312.blue.png" alt="" border="0" /><br /></a>&nbsp;<a href="https://technet.microsoft.com/en-us/library/dn280950.aspx">https://technet.microsoft.com/en-us/library/dn280950.aspx</a></p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp; This page cannot be found anywhere on the file system. It&rsquo;s dynamically generated (based on your identity providers) by ADFS at run time. Because of this, you can&rsquo;t find the page on the file system and modify it.</p>
<p>&nbsp;&nbsp;&nbsp; Now, to be fair, Microsoft made their HRD page super easy to customize as defined in this TechNet article, titled &ldquo;<a href="https://technet.microsoft.com/en-us/library/dn280950.aspx">Customizing the AD FS Sign-in Pages</a>&rdquo;.</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; You can change the logo image, illustration image, description text, etc. Unfortunately, that&rsquo;s not good enough for this project. We really want to make this page integrate with the feel of the overall application. Just changing logo and description enough. Luckily, Microsoft gives us the tools we need, to really do anything we want on this page.</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp; Before I get started, I want to say that I don&rsquo;t want a &ldquo;hack solution&rdquo;. I won&rsquo;t destroy or lose any logic that the page uses already. I just want to tailor that logic into my &ldquo;custom&rdquo; page.</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp; In addition to being able to set the basic properties described in the TechNet article listed above, we can also set JavaScript to be called in the page. The JavaScript is not in a function, it just drops it in a script tag in the body. This means that it will run when the page loads. You will need some basic JavaScript experience, but I&rsquo;ll do most of the heavy lifting for you.</p>
<p>&nbsp;</p>
<p>To set the JavaScript on this page use the PowerShell cmdlet:</p>
<p><a href="https://technet.microsoft.com/en-us/library/dn479318.aspx">Set-AdfsWebTheme</a> (click for documentation)</p>
<p>We will use the &ndash;AdditionalFileResource flag to specify we want to load some JavaScript in the page.</p>
<p>&nbsp;Here is a sample:</p>
<p>Set-AdfsWebTheme -TargetName ADAM -AdditionalFileResource @{Uri=&rsquo;/adfs/portal/script/onload.js&rsquo;;path='C:\ZnHub PowerShell\DefaultWebTheme\script\onload.js'}</p>
<p>&nbsp;</p>
<p>This will load my code JavaScript code located in &ldquo;C:\ZnHub PowerShell\DefaultWebTheme\script\onload.js&rdquo;. Ok.. great! so what.. well, we can do everything from here! Let&rsquo;s take a look at some of my code.</p>
<p>&nbsp;</p>
<p>First I want to hide (<strong>but not destroy the existing code!):</strong></p>
<p>var cw = document.getElementById('contentWrapper').style.diplay = "none";</p>
<p>var bw = document.getElementById('brandingWrapper').style.display = "none";</p>
<p>var fp = document.getElementById('fullPage').style.height = 0;</p>
<p>&nbsp;</p>
<p>I&rsquo;m finding the elements that they use, and hiding them. I set the fulPage l &lt;div&gt; to a height of 0, because I don&rsquo;t&rsquo; want any unnecessary scrollbars to pop up.</p>
<p>&nbsp;</p>
<p>Now I want to create my page. I am going to do this by creating a new &lt;div&gt; tag. I&rsquo;ll put all my HTML page markup code in that tag. Finally, I will add that &lt;div&gt; to the body element of the JavaScript DOM.</p>
<p>Here&rsquo;s a look at some code:</p>
<p>&nbsp;</p>
<p>var iDiv =&nbsp; "&lt;nav class='navbar navbar-default'&gt;&lt;span&gt;&lt;a&nbsp; class='navbar-brand' href='https://www.microsoft.com'&gt;&lt;img style='margin-top:-4px' title='Microsoft' src='/adfs/portal/logo/logo.png' alt='' /&gt;&lt;/a&gt;&lt;a class='navbar-brand'&gt;ZN Sample Services&lt;/a&gt;&lt;span&gt;&lt;/nav&gt;&lt;/br&gt;&lt;/br&gt;&lt;/br&gt;&lt;center&gt;&lt;a class='btn btn-success btn-lg' onclick=\"HRD.selection('https://corp.sts.zn.com')\"&gt;Zn Employee Sign In&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a class='btn btn-info btn-lg' onclick=\"HRD.selection('https://vmastest.accesscontrol.windows.net/')\"&gt;Sign in with Windows Live&lt;/a&gt;&lt;/br&gt;&lt;/br&gt;&lt;/br&gt;&lt;img class='largeIcon float' src='/adfs/portal/illustration/illustration.png' height=500/&gt;&lt;/center&gt;";</p>
<p>&nbsp;</p>
<p>Believe it or not, that&rsquo;s my whole page! And it&rsquo;s beautiful! Now some notes:</p>
<p>&nbsp;</p>
<p>First of all, the code has to be on <strong>one line</strong>. You cannot have carriage returns when building your &lt;div&gt; like I do.</p>
<p>Second, <strong>no double quotes are allowed</strong>.</p>
<p>&nbsp;So</p>
<p>&lt;a href = &rdquo;test&rdquo; &gt;</p>
<p>Becomes</p>
<p>&lt;a href = &lsquo;test&rsquo; &gt;</p>
<p>&nbsp;</p>
<p>Now there is one super catch this. <strong>When calling a function, you have use double quotes so you must escape them like this</strong>:</p>
<p>&lt;a onclick=&rdquo;test()&rdquo;&gt;</p>
<p>Becomes</p>
<p>&lt;a onclick=/&rdquo;test()/&rdquo;&gt;</p>
<p>&nbsp;</p>
<p>Be careful when working on the page, do small parts and test often!</p>
<p>&nbsp;</p>
<p>One thing you&rsquo;ll notice in my HTML code, is that I am using a lot of styles. Better believe it!. there is a cmdlet that allows you to specify the CSS file you want the HRD to use:</p>
<p>&nbsp;</p>
<p>SetAdfsWebTheme &ndash;StyleSheet</p>
<p>&nbsp;</p>
<p>Use it just like we did to load the JavaScript. Now you have use all the styles that you use in your app, in the HRD! Very powerful.</p>
<p>&nbsp;</p>
<p>My code above is very small. That&rsquo;s because most of the content is static.. it doesn&rsquo;t ever change. Instead of trying to HTML mark up all this static conent.. I just took a screenshot capture of the static content. I then use that image to display all the content. This is much easier than building all that HTML ark up in the &lt;div&gt; tag (though you can).</p>
<p>&nbsp;</p>
<p>To use an image like I did, you can use the SetADFSWebTheme &ndash;Illistration cmdlet. Same syntax and use. Now you can use that image with the following source:</p>
<p>&nbsp;</p>
<p>src='/adfs/portal/illustration/illustration.png'</p>
<p>&nbsp;</p>
<p>Really simple&hellip; don&rsquo;t forget you can also use the SetADFSWebTheme &ndash;Logo cmdlet to load images as well.</p>
<p>An even better solution, especially if you don't want to touch the default theme is to use, and if you have to add lots of buttons or style sheets, is to use:</p>
<p>&nbsp;</p>
<p><span style="color: #0000ff;">Set-AdfsWebTheme</span>-TargetNameVS-AdditionalFileResource @{Uri=&rsquo;/adfs/portal/images/live.png';path='C:\HRD\live.png'}&nbsp;</p>
<p>&nbsp;</p>
<p>This is really they key to adding resources. By specifying a Uri (the cmdlet function takes an array of hashtables). Now we can access the resources in our code like this:</p>
<p>&nbsp;</p>
<p>&lt;img source=adfs/portal/images/live.png'/&gt;</p>
<p>&nbsp;</p>
<p>This cmdlet takes and file type, so you can do this with anything you need to build your page.</p>
<p>&nbsp;</p>
<p>The last part of my code is wiring up our buttons just the default HRD so they send me off to login. Remember earlier, I said that I don&rsquo;t want to do anything funky, I just want to do the same thing the original page did. So let&rsquo;s look at the source of the default HDR page. Here we see that what happens, when a provider is selected, we call the HRD.selection JavaScript function with the correct realm, which in turn then posts the form back to ADFS which the correct payload, and ADFS takes over from there.</p>
<p>Remember we didn&rsquo;t clobber any original page code, so we can do EXACTLY as the original page does and call that JavaScript function:</p>
<p>&nbsp;</p>
<p><strong>HRD.selection('https://zntest.accesscontrol.windows.net/')</strong></p>
<p>&nbsp;</p>
<p>This will do exactly the same thing as their buttons do when clicked (essentially call the JavaScript HRD function and post the form back to ADFS.</p>
<p>&nbsp;</p>
<p>To find your realms, bring the default HRD page up in a browser. In the options, view the source of the page and search for HRD.selection. This will yield you your realms as they should be used.</p>
<p>If you wanted the HRD page to be totally skipped, and go directly to the zntest provider for exmaple, you just put this code in the JavaScript:</p>
<p>&nbsp;</p>
<p>HRD.selection('https://zntest.accesscontrol.windows.net");</p>
<p>&nbsp;</p>
<p>And you&rsquo;re done!.. as soon as the page loads, it will go to the zntest realm.</p>
<p>&nbsp;</p>
<p>I use it in a button click like this:</p>
<p>&nbsp;</p>
<p>&lt;a onclick=\"<strong>HRD.selection('https://zntest.accesscontrol.windows.net</strong>/')\"&gt;</p>
<p>&nbsp;</p>
<p>The last thing we have to do is add our newly created &lt;div&gt; tag to the body element:</p>
<p>&nbsp;</p>
<p>document.body.innerHTML += iDiv;&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Here is a look at my finished page, note I had to cut up actual images and text, but you get it:</p>
<p>&nbsp;</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/87/03/3566.fin.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-87-03/3566.fin.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/87/03/3566.fin.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-87-03/3566.fin.png" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>As always hope this helps!</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>How to Dynamically size a data bound control by it's content</title>
      <link>https://docs.microsoft.com/archive/blogs/adam/how-to-dynamically-size-a-data-bound-control-by-its-content</link>
      <pubDate>Thu, 18 Dec 2014 10:23:00 GMT</pubDate>
      <dc:creator><![CDATA[Bambam9876]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/adam/2014/12/18/how-to-dynamically-size-a-data-bound-control-by-its-content/</guid>
      <description><![CDATA[I've seen this question posted on the web, and I have been personally asked to do this a couple of...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">I've seen this question posted on the web, and I have been personally asked to do this a couple of times.</span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">There comes a time when we will need to have buttons (or radioButtons, any control) that needs to have it's width dynamically assigned based on the content within, for example a button with the text "MyButton, should be wide enough to display all the text, but another button next to it should have the same padding but a smaller width if it's content was "Small". This gets even more confusing when we have a list of items that are data bound. You cannot set individual widths for items that are not yet created.</span></p>
<p>&nbsp;</p>
<p><span style="font-size: small;">I'm going to show you how you can accomplish this using a MVVM Converter (<a href="https://msdn.microsoft.com/en-us/library/system.windows.data.binding.converter(v=vs.110).aspx">https://msdn.microsoft.com/en-us/library/system.windows.data.binding.converter(v=vs.110).aspx)</a>.</span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">First let's define our list:&nbsp;</span></p>
<p>&nbsp;</p>
<p><span style="font-size: small;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #0000ff;">public </span>ObservableCollection</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">&lt;</span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">string</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">&gt; ButtonNames</span></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br /><span style="font-size: small;">{</span><br /><span style="font-size: small;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp; get</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> { </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">return</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> _buttonNames; }<br /></span></span> }</span></p>
<p><span style="font-size: small;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">private </span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">ObservableCollection</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">&lt;</span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">string</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">&gt; _buttonNames = </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">new </span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">ObservableCollection</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">&lt;</span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">string</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">&gt;();</span></span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Let's add some strings to our ButtonNames dependency property:</span></p>
<p>&nbsp;</p>
<p><span style="font-size: small;">&nbsp;_buttonNames.Add(<span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">"Short"</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">);<br /></span></span>&nbsp;_buttonNames.Add(<span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">"LongerName"</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">);<br /></span></span>OnPropertyChanged(<span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">"ButtonNames"</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">);</span></span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">Pretty simple.. now we'll create an ItemsControl to bind to our ButtonNames collection:</span></p>
<p>&nbsp;</p>
<p><span style="font-size: small;">&lt;<span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">ItemsControl</span></span></span><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"> ItemsSource</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">="{</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">Binding</span></span></span><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"> ButtonNames</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">}" &gt;<br /></span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp; &lt;</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">ItemsControl.ItemsPanel</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&gt;<br /></span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">ItemsPanelTemplate</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&gt;<br /></span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">StackPanel</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #ff0000;"> Orientation<span style="color: #0000ff;">="Horizontal"</span></span>/&gt;<br /></span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">ItemsPanelTemplate</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&gt;<br /></span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp; &lt;/</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">ItemsControl.ItemsPanel</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&gt;<br /></span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp; &lt;</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">ItemsControl.ItemTemplate</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&gt;<br /></span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">DataTemplate</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&gt;<br /></span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">Button</span></span></span><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"> Content</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">="{</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">Binding</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">}"</span></span></span><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"> Width</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">="50"</span></span></span><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"> Height</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">="30" /&gt;<br /></span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">DataTemplate</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&gt;<br /></span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp; &lt;/</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">ItemsControl.ItemTemplate</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&gt;<br /></span></span></span>&lt;/<span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">ItemsControl</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&gt;</span></span></span></span></p>
<p><br /><span style="font-family: arial,helvetica,sans-serif; font-size: small;">If we run this, we see our problem:</span></p>
<p>&nbsp;</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/87/03/1541.a.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-87-03/1541.a.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/87/03/1541.a.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x550/__key/communityserver-blogs-components-weblogfiles/00-00-00-87-03/1541.a.JPG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">The buttons are stuck with the wrong width.(say that fast three times!)</span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">To fix this, I am going to bind the width of our button to the string we are using for content. The problem is, the property is expecting an int, So we need a converter:</span></p>
<p>&nbsp;</p>
<p><span style="font-size: small;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">class </span></span></span>WidthHelper</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> : </span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">IValueConverter<br /></span></span></span>{</span><br /><span style="font-size: small;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">object</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> Convert(</span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">object</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> value, </span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Type</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> targetType, </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">object</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> parameter, System.Globalization.</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">CultureInfo</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> culture)<br /></span></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><br /><span style="font-size: small;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> nameLength = value.ToString().Length;<br /></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> (14 * nameLength) + 20;<br /></span></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p><span style="font-size: small;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp; public </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">object</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> ConvertBack(</span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">object</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> value, </span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Type</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> targetType, </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">object</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> parameter, System.Globalization.</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">CultureInfo</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> culture)<br /></span></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><br /><span style="font-size: small;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">new </span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">NotImplementedException</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">();<br /></span></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br /><span style="font-size: small;">}</span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">What's great about the implemented Convert function is that the value coming in is an object, so we can pass in a string.. or whatever we want. As long as we match the targetType.. we're good. So as you can see I multiply 14 (that's the font size I am using) times the number of characters in the name, I then put a 10 pixel buffer on each side of the text (+20).</span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;">I can now wire up ourconverter to our ItemsControl data template:</span></p>
<p>&nbsp;</p>
<p><span style="font-size: small;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #000000; font-family: Arial;">&lt;</span>Button</span></span></span><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"> Content</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">="{</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">Binding</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">}"</span></span></span><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"> Width</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">="{</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">Binding</span></span></span><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"> Converter</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">,</span></span></span><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;">Converter</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">={</span></span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">StaticResource</span></span></span><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"> WidthHelper</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">}}"</span></span></span><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"><span style="color: #ff0000; font-family: Consolas;"> Height</span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">="30" /&gt;</span></span></span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: small;">Our buttons now display with the dynamic width</span>:</span></p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/87/03/1016.b.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-87-03/1016.b.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/87/03/1016.b.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x550/__key/communityserver-blogs-components-weblogfiles/00-00-00-87-03/1016.b.jpg" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif;">Pretty cool!</span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif;">&nbsp;Hope this helps!</span></p>]]></content:encoded>
    </item>
    <item>
      <title>How to get a callback from a DataBound property</title>
      <link>https://docs.microsoft.com/archive/blogs/adam/how-to-get-a-callback-from-a-databound-property</link>
      <pubDate>Wed, 02 Apr 2014 18:10:00 GMT</pubDate>
      <dc:creator><![CDATA[Bambam9876]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/adam/2014/04/02/how-to-get-a-callback-from-a-databound-property/</guid>
      <description><![CDATA[&nbsp;&nbsp; I'm writing this blog to show something that stumped me for about an hour, and...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;&nbsp; I'm writing this blog to show something that stumped me for about an hour, and hopefully this will save you some time.. or at least get you thinking creative!</p>
<p>&nbsp;</p>
<p>&nbsp; I have a user control in Silverlight, I'm using C# on the back end. The control's background color changes via viewmodel databinding. What I want to do, is get a callback when the background color changes. so I can start my storyboard which is a nice transition into the UI change of the control.</p>
<p>&nbsp;&nbsp;Here's an idea of my control:</p>
<p>&nbsp;</p>
<p>&lt;<span style="color: #993300;">Grid</span><span style="color: #ff0000;"> x:Name</span><span style="color: #0000ff;">="LayoutRoot</span>" <strong><span style="color: #ff0000;">Background</span>="{<span style="color: #993300;">Binding </span><span style="color: #ff0000;">Background</span>}"</strong> <span style="color: #ff0000;">Height</span>="<span style="color: #0000ff;">85</span>" <span style="color: #0000ff;">Width="300</span>" &gt;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;<span style="color: #993300;">Grid.Resources</span>&gt;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;<span style="color: #ff0000;">Storyboard</span> <span style="color: #ff0000;">x:Name</span><span style="color: #0000ff;">="animate"&gt;</span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;<span style="color: #993300;">DoubleAnimationUsingKeyFrames</span> <span style="color: #ff0000;">Storyboard.TargetProperty</span><span style="color: #0000ff;">="(UIElement.Opacity)"</span><span style="color: #ff0000;"> Storyboard.TargetName</span><span style="color: #0000ff;">="LayoutRoot</span>"&gt;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #993300;">&lt;EasingDoubleKeyFrame </span><span style="color: #ff0000;">KeyTime</span><span style="color: #0000ff;">="0"</span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="0</span>"/&gt;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;<span style="color: #993300;">EasingDoubleKeyFrame</span><span style="color: #ff0000;"> KeyTime</span>="<span style="color: #0000ff;">0:0:1.0</span>"<span style="color: #ff0000;"> Value</span><span style="color: #0000ff;">="1</span>"/&gt;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #993300;">&lt;/DoubleAnimationUsingKeyFrames</span>&gt;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #993300;">&lt;/Storyboard</span>&gt;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #993300;">&lt;/Grid.Resources</span>&gt;</p>
<p>&nbsp;&nbsp;&nbsp; ...</p>
<p>&nbsp;&nbsp; <span style="color: #993300;">&lt;/Grid</span>&gt;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp; I spent a lot of time trying to do things like hook into the BIndingExpression and&nbsp;trying to wire up different ways to hook up to this control. Nothing, was, for lack of better terms, code pretty or really functional. I also&nbsp;really only care about when the background property on the Grid control changes.&nbsp;So how can this be accomplished? The answer is that you don't need to look up anything, you have all the knowledge to do this, you just have to think about it.</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp; The Grid control is a bad control for what we want.. it just doesn't give me what I need, a callback when the data (that again is Databound somewhere in a viewmodel) changes. But think about it.. other controls do have this functionality! The textbox control for one does! And that works perfectly for us. Let's add a textbox control to our user control:</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&lt;<span style="color: #993300;">TextBox</span> <strong><span style="color: #ff0000;">TextChanged</span><span style="color: #0000ff;">="TextBox_TextChanged</span>"</strong> <span style="color: #ff0000;">Text</span>="{<span style="color: #993300;">Binding</span> <span style="color: #ff0000;">Background</span>}" <span style="color: #ff0000;">Opacity=<span style="color: #0000ff;">"0"</span></span>/&gt;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp; The textbox control will now callback into the code anytime the Background (which in my case is a Solid Color brush) changes. Now all I have to do is wire up the event handler:</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> TextBox_TextChanged(<span style="color: #0000ff;">object</span> sender, <span style="color: #33cccc;">TextChangedEventArgs</span> e)</p>
<p>{</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; animate.Begin();</p>
<p>&nbsp;}</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp; So pretty easy to do, and the code is not freaky.. it's straight forward and consistent. It also allows me to wire up many textbox controls if necessary to monitor different property changes.</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;Enjoy!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>How to use a Dependency Property in a XAML Style</title>
      <link>https://docs.microsoft.com/archive/blogs/adam/how-to-use-a-dependency-property-in-a-xaml-style</link>
      <pubDate>Sun, 29 Dec 2013 15:27:00 GMT</pubDate>
      <dc:creator><![CDATA[Bambam9876]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/adam/2013/12/29/how-to-use-a-dependency-property-in-a-xaml-style/</guid>
      <description><![CDATA[In this post I will demonstrate how to create a dependency property and then use that property in a...]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: medium;">In this post I will demonstrate how to create a dependency property and then use that property in a XAML style.</span></p>
<p><span style="font-size: medium;">I have found samples on the internet for each, but not a comprehensive example for both. Hopefully putting these pieces all together for you will save you some time!</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">First we must declare the dependency property. It must be an<a title=" attached dependency property " href="https://msdn.microsoft.com/en-us/library/ms749011(v=vs.110).aspx"> <strong>attached </strong>dependency property</a> to be used in xaml. In this sample I am going to create a button that has a new property called HasPlayButton and another property called HasStopButton to display or hide a path on a checkbox control. This sample will work for Silverlight, Windows Store Apps, Windows Phone Apps and WPF apps, pretty much anything that uses XAML.</span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">First&nbsp;we'll make our new Checkbox control. This is just a simple control that inherits from the Checkbox control. I will be adding two dependency properties to this class:</span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">partial </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">class </span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">AppButtton</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> : </span></span></span><span style="color: #2b91af; font-family: Consolas; font-size: x-small;"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;"><span style="font-size: medium;">Checkbox</span><br /></span></span></span>{<br /><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp; public </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">static </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">readonly </span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">DependencyProperty</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> HasPlayButtonProperty = </span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">DependencyProperty</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">.RegisterAttached(</span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">"HasPlayButton"</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">, </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">typeof</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">), </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">typeof</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">AdamButton</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">), </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">new </span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">PropertyMetadata</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">.Visible));</span></span></span></p>
<p><span style="font-size: medium;">&nbsp;&nbsp;&nbsp; <span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">public </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">static </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">void</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> SetHasPlayButton(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">AdamButton</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> element, </span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> value)</span></span>&nbsp;&nbsp;<br /></span><span style="font-size: medium;">&nbsp;&nbsp;&nbsp;&nbsp;{</span></p>
<p><span style="font-size: medium;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; element.SetValue(HasPlayButtonProperty, value);<br />&nbsp;&nbsp;&nbsp; </span><span style="font-size: medium;">}</span></p>
<p><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;public </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">static </span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> GetHasPlayButton(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">AdamButton</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> element)<br />&nbsp;&nbsp;</span></span></span><span style="font-size: medium;">{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">return</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> (</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">)element.GetValue(HasPlayButtonProperty);<br />&nbsp;&nbsp;</span></span></span><span style="font-size: medium;">}<br /><br />&nbsp;&nbsp;&nbsp; </span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">public</span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> HasPlayButton<br />&nbsp; </span></span></span><span style="font-size: medium;">{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">get</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> { </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">return</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> (</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">)GetValue(HasPlayButtonProperty); }<br /><br />&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">set</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> { SetValue(HasPlayButtonProperty, </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">value</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">); }<br />&nbsp; </span></span></span><span style="font-size: medium;">}</span></p>
<p><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp; public </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">static </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">readonly </span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">DependencyProperty</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> HasStopButtonProperty = </span></span></span><span style="font-size: medium;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">DependencyProperty</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">.RegisterAttached(</span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">"HasStopButton"</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">, </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">typeof</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">), </span></span></span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">typeof</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">AdamButton</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">), </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">new</span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">&nbsp; PropertyMetadata</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">.Collapsed));<br /><br /></span></span></span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp; public </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">static </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">void</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> SetHasStopButton(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">CheckBox</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> element, </span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> value)<br /></span></span></span><span style="font-size: medium;">&nbsp;&nbsp;&nbsp; {<br />&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</span><span style="font-size: medium;">element.SetValue(HasStopButtonProperty, value);<br /></span><span style="font-size: medium;">&nbsp;&nbsp;&nbsp; }<br /><br /></span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp; public </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">static </span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> GetHasStopButton(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">CheckBox</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> element)<br /></span></span></span><span style="font-size: medium;">&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">return</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> (</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">)element.GetValue(HasStopButtonProperty);<br /></span></span></span><span style="font-size: medium;">&nbsp;&nbsp;&nbsp; }<br /><br /></span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;public </span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> HasStopButton<br /></span></span></span><span style="font-size: medium;">&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">get</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> { </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">return</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> (</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">)GetValue(HasStopButtonProperty); }<br /><br />&nbsp;&nbsp; &nbsp;</span></span></span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">set</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> { SetValue(HasStopButtonProperty, </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">value</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">); }<br /></span></span></span><span style="font-size: medium;">&nbsp;&nbsp;&nbsp; }<br /><br /></span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp; public</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> AdamButton()<br /></span></span></span><span style="font-size: medium;">&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: medium;">InitializeComponent();<br /></span><span style="font-size: medium;">&nbsp;&nbsp;&nbsp; }<br /></span><span style="font-size: medium;">}</span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">&nbsp;Let's look at the definition of the first dependency property:</span><br /><br /><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #000000; font-family: Arial;">&nbsp;&nbsp; </span>public static </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">readonly </span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">DependencyProperty</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> HasPlayButtonProperty = </span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">DependencyProperty</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">.RegisterAttached(</span></span><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;"><span style="color: #a31515; font-family: Consolas;">"HasPlayButton"</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">, </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">typeof</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">), </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">typeof</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">AdamButton</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">), </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">new </span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">PropertyMetadata</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">.Visible));</span></span></span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">You can see that I have defined this as an attached property:</span></p>
<p><span style="font-size: medium;">&nbsp;&nbsp;&nbsp; <span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">DependencyProperty</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">.RegisterAttached</span></span></span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">Next I have to set the type for the value that this property will use. I am using the Visibility type so I can hide my path elements later.</span></p>
<p><span style="font-size: medium;">The next parameter is the type that I am setting this property on, which is AdamButton (my custom control).<br /><br /></span><span style="font-size: medium;">The last parameter is the default value of this property, which we pass in via the PropertyMetadata class.<br /><br /><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">new</span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">&nbsp; PropertyMetadata</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">.Collapsed<br /><br /><br /></span></span></span><span style="font-size: medium;">Since this is an attached dependency property, we must implement both the Setter and Getter for the property, note, you <strong>must</strong> use the naming convention followed below:</span>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;public </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">static </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">void</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> SetHasPlayButton(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">AdamButton</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> element, </span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> value)</span></span>&nbsp;&nbsp;</span><br /><span style="font-size: medium;">&nbsp;&nbsp;&nbsp; {</span></p>
<p><span style="font-size: medium;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; element.SetValue(HasPlayButtonProperty, value);<br />&nbsp;&nbsp;&nbsp;&nbsp;}</span></p>
<p><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;public </span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">static </span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> GetHasPlayButton(</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">AdamButton</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> element)<br />&nbsp;&nbsp;</span></span>{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">return</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> (</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">)element.GetValue(HasPlayButtonProperty);<br />&nbsp;&nbsp;</span></span>}<br /><br /><br />The last step to complete our custom button is to define the regular normal property on the AdamButton class. This allows our class to be aware of these properties as well.</span></p>
<p><span style="font-size: medium;"><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">&nbsp;&nbsp;public</span></span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> HasPlayButton<br />&nbsp; </span></span></span><span style="font-size: medium;">{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">get</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> { </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">return</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> (</span></span><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">)GetValue(HasPlayButtonProperty); }<br /><br />&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">set</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"> { SetValue(HasPlayButtonProperty, </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">value</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">); }<br />&nbsp; </span></span></span><span style="font-size: medium;">}</span></span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">Our class is now complete and we may use the AdamButton class with the new HasStopButton and HasPlayButton properties any where in xaml.<br /></span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">I am going to create a <a title="style" href="https://msdn.microsoft.com/en-us/library/ms752319(v=vs.110).aspx">style</a> for the AdamButton control. This style will implement the new properties we defined above via Template binding in xaml. Before we can use our AdamButton class in xaml,&nbsp;we must first declare it's namespace:<br /><br /></span><span style="font-size: medium;"><span style="color: #ff0000;">xmlns<span style="font-family: Consolas;"><span style="font-family: Consolas;"><span style="font-family: Consolas;">:</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;"><span style="font-family: Consolas;">a</span></span></span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">="clr-namespace:PhoneApp2"</span></span></span></span></p>
<p><span style="font-size: medium;">Add this to your root node for your application or app.xaml file.<br /><br /><br />Now&nbsp;we can user our&nbsp;new properties via the AdamButton class in a style.</span><span style="font-size: medium;">&nbsp;Let's take a look at the Style:<br /><br /></span><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&lt;</span><span style="color: #993300;">Style</span> x:Key <span style="color: #0000ff;">="</span>PlayButtonStyleLarge" TargetType<span style="color: #3366ff;">="CheckBox"&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">Setter</span> Property<span style="color: #3366ff;">="Background"</span> Value<span style="color: #3366ff;">="#FF448DCA</span><span style="color: #0000ff;">"/&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">Setter</span> Property<span style="color: #3366ff;">="BorderThickness"</span> <span style="color: #3366ff;">Value="0"/</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">Setter</span> Property<span style="color: #3366ff;">="MinWidth"</span> Value<span style="color: #3366ff;">="50"/</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">Setter</span> Property<span style="color: #3366ff;">="MinHeight"</span> Value<span style="color: #3366ff;">="19"/</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">Setter</span> Property<span style="color: #3366ff;">="Template</span><span style="color: #0000ff;">"&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #993300;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span>Setter.Value</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">ControlTemplate</span> TargetType<span style="color: #3366ff;">="a:AdamButton</span><span style="color: #0000ff;">"&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">Border</span> BorderBrush<span style="color: #3366ff;">="{<span style="color: #993300;">TemplateBinding</span> BorderBrush}"</span> BorderThickness<span style="color: #3366ff;">="{<span style="color: #993300;">TemplateBinding</span> BorderThickness}"</span> <span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">VisualStateManager.VisualStateGroups</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">VisualStateGroup</span> x:Name<span style="color: #3366ff;">="CommonStates"&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">VisualState</span> x:Name<span style="color: #3366ff;">="Normal"/</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">VisualState</span> x:Name<span style="color: #3366ff;">="MouseOver"</span> <span style="color: #0000ff;">/&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">VisualState</span> x:Name<span style="color: #3366ff;">="Pressed" /</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">VisualState</span> x:Name<span style="color: #3366ff;">="Disabled"</span> <span style="color: #0000ff;">/&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #993300;">VisualStateGroup</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #993300;">VisualStateGroup</span> x:Name<span style="color: #3366ff;">="CheckStates"</span> <span style="color: #0000ff;">/&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">VisualStateGroup</span> x:Name<span style="color: #3366ff;">="FocusStates</span><span style="color: #0000ff;">"&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">VisualState</span> x:Name<span style="color: #3366ff;">="Focused"</span> <span style="color: #0000ff;">/&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">VisualState</span> x:Name<span style="color: #3366ff;">="Unfocused</span><span style="color: #0000ff;">" /&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/<span style="color: #993300;">VisualStateGroup</span>&gt;</span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span>/<span style="color: #993300;">VisualStateManager.VisualStateGroups</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">Grid</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">Border</span> x:Name<span style="color: #3366ff;">="ButtonBackground</span><span style="color: #0000ff;">"</span> BorderBrush<span style="color: #3366ff;">="{<span style="color: #993300;">TemplateBinding</span></span> BorderBrush<span style="color: #0000ff;">}"</span> BorderThickness<span style="color: #3366ff;">="{<span style="color: #993300;">TemplateBinding</span></span> BorderThickness<span style="color: #0000ff;">}"</span> Background=<span style="color: #0000ff;">"{</span><span style="color: #993300;">TemplateBinding</span> Background<span style="color: #0000ff;">}"</span> CornerRadius<span style="color: #0000ff;">="0"</span> Margin<span style="color: #0000ff;">="{</span><span style="color: #993300;">StaticResource</span> PhoneTouchTargetOverhang}<span style="color: #0000ff;">"&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">Grid</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #993300;">Polygon</span> Points<span style="color: #3366ff;">="0,00 50,30, 0,65"</span> Fill<span style="color: #3366ff;">="White"</span> Name<span style="color: #3366ff;">="StartPoly</span>" VerticalAlignment<span style="color: #3366ff;">="Center"</span> HorizontalAlignment<span style="color: #3366ff;">="Center"</span> Visibility=<span style="color: #0000ff;">"{</span><span style="color: #993300;">TemplateBinding</span> HasPlayButton}" <span style="color: #0000ff;">/&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">Polygon</span> Points<span style="color: #3366ff;">="0,0 50,0, 50,50 0,50"</span> Fill<span style="color: #3366ff;">="White</span>" Name<span style="color: #3366ff;">="</span>StopPoly" &nbsp;VerticalAlignment<span style="color: #3366ff;">="Center"</span> HorizontalAlignment<span style="color: #3366ff;">="Center</span>" Visibility=<span style="color: #0000ff;">"{</span><span style="color: #993300;">TemplateBinding</span> HasStopButton}<span style="color: #0000ff;">"/&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #993300;">ContentControl</span> x:<span style="color: #3366ff;">Name="ContentContainer"</span> ContentTemplate<span style="color: #0000ff;">="{</span><span style="color: #993300;">TemplateBinding</span> ContentTemplate}<span style="color: #0000ff;">"</span> Foreground<span style="color: #0000ff;">="{</span><span style="color: #993300;">TemplateBinding</span> Foreground<span style="color: #0000ff;">}"</span> HorizontalContentAlignment<span style="color: #0000ff;">="{</span><span style="color: #993300;">TemplateBinding</span> HorizontalContentAlignment<span style="color: #0000ff;">}"</span> Padding<span style="color: #0000ff;">="{</span><span style="color: #993300;">TemplateBinding</span> Padding<span style="color: #0000ff;">}"</span> VerticalContentAlignment<span style="color: #0000ff;">="{</span><span style="color: #993300;">TemplateBinding</span> VerticalContentAlignment<span style="color: #0000ff;">}" </span>/&gt;</span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span>/<span style="color: #993300;">Grid</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #993300;">Border</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #993300;">Grid</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #993300;">Border</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #993300;">ControlTemplate</span>&gt;</span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #993300;">Setter.Value</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #993300;">Setter</span><span style="color: #0000ff;">&gt;</span></span><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="color: #993300;">Style</span><span style="color: #0000ff;">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></p>
<p>&nbsp;</p>
<p><span style="font-size: medium;">Notice the target type for the style is still set to Checkbox, because that is our base class style that xaml (and .net)&nbsp;can recognize:<br /><br /><span style="color: #ff0000; font-size: medium;"><span style="color: #0000ff;">&lt;</span><span style="color: #993300;">Style</span> x:Key <span style="color: #0000ff;">="</span>PlayButtonStyleLarge" TargetType<span style="color: #3366ff;">="CheckBox"&gt;</span></span></span>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="color: #000000; font-size: medium;"><span style="font-size: medium;">However the control template is set to our AdamButton class. This allows me to access my new properties via the control's template binding:<br /><br />&lt;<span style="color: #993300;">ControlTemplate</span> TargetType<span style="color: #3366ff;">="a:AdamButton</span><span style="color: #0000ff;">"&gt;<br /><br /><span style="color: #000000;">The "a:" here is our namespace reference we defined earlier.</span></span></span></span></p>
<p>&nbsp;</p>
<p><span style="color: #000000; font-size: medium;"><span style="font-size: medium;">In my control style I set the visibility of the different paths with our <strong>new property</strong>:<br /><br /></span></span><span style="color: #000000; font-size: medium;"><span style="font-size: medium;">&lt;<span style="color: #993300;">Polygon</span> <span style="color: #ff0000;">Points</span><span style="color: #3366ff;">="0,00 50,30, 0,65"</span> <span style="color: #ff0000;">Fill</span><span style="color: #3366ff;">="White"</span> <span style="color: #ff0000;">Name</span><span style="color: #3366ff;">="StartPoly</span>" <span style="color: #ff0000;">VerticalAlignment</span><span style="color: #3366ff;">="Center"</span> <span style="color: #ff0000;">HorizontalAlignment</span><span style="color: #3366ff;">="Center"</span> <span style="font-size: large;"><span style="color: #ff0000;">Visibility</span>=<span style="color: #0000ff;">"{</span><span style="color: #993300;">TemplateBinding</span> HasPlayButton}"</span> <span style="color: #0000ff;">/&gt;<br /><br /></span></span></span><span style="color: #000000; font-size: medium;"><span style="font-size: medium;"><br /><br />We now have a button that we can easily style with our new properties in C# code behind. Here's an example of how we can use the AdamButton class:<br /><br /></span></span><span style="font-size: medium;">if <span style="font-family: Consolas;"><span style="font-family: Consolas;">(</span></span><em><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">&lt;value&gt;</span></span></span></em><span style="font-family: Consolas;"><span style="font-family: Consolas;">== </span></span><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">true</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">)<br /></span></span>{</span><br /><span style="font-size: medium;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Button1.HasPlayButton = <span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">.Collapsed;<br />&nbsp;&nbsp; &nbsp;</span></span>Button1.HasStopButton = <span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">.Visible;<br /></span></span>}</span></p>
<p><span style="font-size: medium;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;"><span style="color: #0000ff; font-family: Consolas;">else<br /></span></span></span>{</span><br /><span style="font-size: medium;">&nbsp; &nbsp;&nbsp; &nbsp; Button1.HasPlayButton = <span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">.Visible;<br /></span></span>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;Button1.HasStopButton = <span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;"><span style="color: #2b91af; font-family: Consolas;">Visibility</span></span></span><span style="font-family: Consolas;"><span style="font-family: Consolas;">.Collapsed;<br /></span></span>}</span></p>
<p><span style="color: #000000; font-size: medium;"><span style="font-size: medium;"><br />Hope this helps guys!</span></span></p>
<p>&nbsp;</p>
<p><span style="color: #000000; font-size: medium;"><span style="font-size: medium;">A</span></span></p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Working with SCVMM 2012 Powershell in C# - InvokePowerShell function</title>
      <link>https://docs.microsoft.com/archive/blogs/adam/working-with-scvmm-2012-powershell-in-c-invokepowershell-function</link>
      <pubDate>Mon, 09 Apr 2012 11:20:00 GMT</pubDate>
      <dc:creator><![CDATA[Bambam9876]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/adam/2012/04/09/working-with-scvmm-2012-powershell-in-c-invokepowershell-function/</guid>
      <description><![CDATA[I have a blog post on Working with SCVMM Powershell in C# - InvokePowerShell funciton, that has been...]]></description>
      <content:encoded><![CDATA[<p>I have a blog post on <a title="Working with SCVMM Powershell in C# - InvokePowerShell funciton" href="https://blogs.msdn.com/b/adam/archive/2010/03/26/working-with-scvmm-powershell-in-c-invokepowershell-function.aspx" target="_blank">Working with SCVMM Powershell in C# - InvokePowerShell funciton</a>, that has been pretty popular and helpful to some. I want to write a subsequent blog post on doing the same thing but what has changed in SCVMM 2012.</p>
<p>SCVMM 2012 has replaced it's pssnapin (<span style="color: #ff6600;">formerly Microsoft.SystemCenter.VirtualMachineManager) <span style="color: #000000;">with a PowerShell module. Modules were introduced in PowerShell v2 and have added functionality over pssnapins. There is plenty on the web on PowerShell modules, and that is not the topic of this blog. In this blog I will show you how to load the SCVMM 2012 PowerShell module so you may make C# calls to SCVMM 2012 via embedded PowerShell.</span></span></p>
<p><br />&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>In my applications, I use the InvokePowerShell function to call into SCVMM any time I need to work with any of the objects managed by SCVMM. My function will take a string parameter that contains the powershell I want to call. In my sample string you will see I add \r\n in my strings. This puts line breaks in the string so that when I debug, and I view my powershell in the Visual Studio debugger windows, the script is very easy to read (and check for errors!).</p>
<p mce_keep="true">The function will return a PSObject. This PSObject will return any errors if occurred, or if successful any information that would be normally seen in the powershell window. I show some examples of how to use this function as well.</p>
<p mce_keep="true">Before you can use this function, you will need to add a reference to the System.Management.Automation.dll. This is not so straight forwarded because this .dll is a little hard to find. Take a look at this article that will help you add this reference.</p>
<p mce_keep="true"><a href="https://www.codeplex.com/wikipage?ProjectName=ShinyPower&amp;title=Frequently%20Asked%20Questions" mce_href="https://www.codeplex.com/wikipage?ProjectName=ShinyPower&amp;title=Frequently%20Asked%20Questions">https://www.codeplex.com/wikipage?ProjectName=ShinyPower&amp;title=Frequently%20Asked%20Questions</a></p>
<p mce_keep="true">Here is link for reference on the System.Management.Automation namespace:</p>
<p mce_keep="true"><a href="https://msdn.microsoft.com/en-us/library/system.management.automation(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/system.management.automation(VS.85).aspx">https://msdn.microsoft.com/en-us/library/system.management.automation(VS.85).aspx</a></p>
<p mce_keep="true">OK.. let's take a look at the function:</p>
<pre class="scroll"><code class="csharp">RunspaceConfiguration rconfig = RunspaceConfiguration.Create();<br /> PSSnapInException Pwarn = new PSSnapInException();<br /> Collection&lt;PSObject&gt; results = new Collection&lt;PSObject&gt;();<br /> Runspace runspace = RunspaceFactory.CreateRunspace();<br /> <br /> string test = "Import-Module VirtualMachineManager\r\n";<br /> runspace = RunspaceFactory.CreateRunspace(rconfig);<br /> runspace.Open();<br /> <br /> pipeline = runspace.CreatePipeline();<br /> pipeline.Commands.AddScript(test);<br /> <br /> <br /> try<br /> {<br /> results = pipeline.Invoke();<br /> }<br /> catch (Exception ex)<br /> {<br /> return ex.Message;<br /> }</code></pre>
<p mce_keep="true"><span style="font-family: Calibri; font-size: small;" size="3" face="Calibri">OK so now we have a function to call our powershell scripts. You will have to check and handle your exceptions yourself. <strong>Do not leave the try-catch like this as you will miss uhandled exceptions.&nbsp; </strong></span></p>
<p><span style="font-family: Calibri; font-size: small;" size="3" face="Calibri">There is one issue you have to be very careful with with this function. If this function is run in a process, and multiple calls to Get-VMMSerrver are called, a connection for each call will be held in the process until the process is taken down. The runspace Close and Dispose call do not clear these out. Avoid calling the generic Get-VMMServer cmdlet with this function. If you must use this cmdlet, make sure that it is only called once, and store a way to check with it with a static variable in your code.</span></p>
<p><span style="font-family: Calibri; font-size: small;" size="3" face="Calibri">Let's take a look at using the InvokePoweShell function. I'll use this function to take a SCVMM host out of placement. I will pass into this function a string for the host name, and a boolean value to set the host available and not available.&nbsp; The function will return true, if it succeeds and false if there is a problem:</span></p>
<p></p>
<p>public bool SetHostAvailabeForPlacement(string HostName, boolean val)</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool retval = true;</p>
<p></p>
<p></p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string psscript = "$MyHost = Get-VMHost -VMMServer localhost -ComputerName '" + HostName + "'\r\n Set-VMHost -VMHost $MyHost -AvailableForPlacement $" + val;</p>
<p></p>
<p></p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Collection&lt;PSObject&gt; results = InvokePowerShell(psscript);</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return retval;</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p></p>
<p>You will notice that in my powershell script, I didn't use the Get-VMMServer function instead I just told the cmdlet which server to use. I also could have made this powershell a little cleaner by making the cmdlet call in one line:</p>
<p></p>
<p><span style="font-size: x-small;" size="2"><span style="font-family: Courier New;" face="Courier New">string psscript = "$MyHost = Get-VMHost -VMMServer localhost -ComputerName '" + HostName + "' | Set-VMHost -AvailableForPlacement $" + val;</span></span></p>
<p><span style="font-family: Calibri; font-size: small;" size="3" face="Calibri"><span style="font-family: Calibri; font-size: small;" size="3" face="Calibri">In this example I'm not looking for any data back so I don't check the results PSObject. See my other blog posts for examples of this.</span></span></p>
<p mce_keep="true"></p>
<p></p>
<p>The last thing I want to demonstrate in this blog is how to use powershell that can be called from C# where you don't need to recompile your code to change the powershell. What I do is read the contents of an external text file into a string. I then parse that string replacing place holders with the values that I need.</p>
<p></p>
<p>public void CallPSFromFile(string FileName)</p>
<p></p>
<p>{</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StreamReader sr = new StreamReader(FileName);</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string psscript = sr.ReadToEnd();</p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sr.Close();</p>
<p></p>
<p></p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string VMName = "MyTestVM";</p>
<p></p>
<p></p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; psscript.Replace("__VMName__", VMName);</p>
<p></p>
<p></p>
<p></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Collection&lt;PSObject&gt; results = InvokePowerShell(psscript);</p>
<p></p>
<p>}</p>
<p></p>
<p mce_keep="true"></p>
<p></p>
<p>This is a very simple function, and in the real world, you will want to make sure that your file read process doesn't error out.&nbsp; The StreamReader is the System.IO namespace, add a Using statement to add it to your code.</p>
<p></p>
<p mce_keep="true"></p>
<p></p>
<p>This function will read in the text from the text file and then replace any occurances of "__VMName__" with my value. I add the underscores to my replacement text to make them easy to find.</p>
<p></p>
<p>Here's a sample text file to remove a VM that can be used with the above sample:</p>
<p></p>
<p>$MyVMs = @(Get-VM -VMMServer VMMServer1.Contoso.com | where { $_.Name -Match "__VMName__" } )</p>
<p></p>
<p>$MyVMs | Remove-VM</p>
<p></p>
<p mce_keep="true"></p>
<p></p>
<p>As always, enjoy!</p>]]></content:encoded>
    </item>
    <item>
      <title>How to Serialize a Dictionary or Hashtable in C#</title>
      <link>https://docs.microsoft.com/archive/blogs/adam/how-to-serialize-a-dictionary-or-hashtable-in-c</link>
      <pubDate>Fri, 10 Sep 2010 06:12:00 GMT</pubDate>
      <dc:creator><![CDATA[Bambam9876]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/adam/2010/09/10/how-to-serialize-a-dictionary-or-hashtable-in-c/</guid>
      <description><![CDATA[&nbsp;&nbsp; This post kind of doesn't fit in with some of my other posts however, I had this...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">&nbsp;&nbsp; This post kind of doesn't fit in with some of my other posts however, I had this question, and when I searched for answers on this, the answers I found were either incomplete, inneficient or outdated. So to make it easy for&nbsp;everyone, I'm writing this complete and up to date blog post (well as of this date any way!).</span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">&nbsp;&nbsp; This post was written using .NET Framework 4.0 and storing my data in SQL Server 2008.</span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">&nbsp;&nbsp; Let's take a look at the problem I had at hand. I needed to be able to store Key\Value pairs from a C# application into SQL. Since I did not know how many key value pairs I might end up with I decided to use the Dictionary object in c#. The problem is, both the </span></span><a target="_blank" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Dictionary" title="https://msdn.microsoft.com/en-us/library/xfhwa508.aspx"><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">Dictionary</span></span></a><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;"> and </span></span><a target="_blank" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Hashtable" title="https://msdn.microsoft.com/en-us/library/system.collections.hashtable.aspx"><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">Hashtable</span></span></a><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;"> classes or not serializabe because they implement the </span></span><a target="_blank" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/IDictionary" title="https://msdn.microsoft.com/en-us/library/s4ys34ea.aspx"><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">IDictionary</span></span></a><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;"> interface. Here's the error that you will get if you try to serialize one of the classes:</span></span></p>
<p><strong><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">System.NotSupportedException was unhandled<br /><br />&nbsp; Message=The type System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] is not supported because it implements IDictionary.<br /></span></span><br />&nbsp; Source=System.Xml<br /><br />&nbsp; StackTrace:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Xml.Serialization.TypeScope.GetDefaultIndexer(Type type, String memberInfo)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, MemberInfo memberInfo, Boolean directReference)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...</strong></p>
<p><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;T</span></span><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">he reason the System.NotSupportedException is thrown is because&nbsp;the IDictionary class implements the </span></span><a target="_blank" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/IXmlSerializable" title="https://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable.aspx"><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">IXmlSerializable</span></span></a><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;"> interface.The IXmlSerializable interface makes us overide the following&nbsp;methods: GetSchema, ReadXml and WriteXml. We can do&nbsp;this, but since we have to write a class to overide these functions anyway, it's easier to just write a generic class and use that for serialization. Let's take a look.</span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">&nbsp;&nbsp; What we are going to do is make&nbsp;a stub class that will be serializbe that <em>mimics</em> the Dictionary or Hashtable DictionaryItem or KeyValuePair&lt;string, string&gt;. We want this class to be a simple a possible:</span></span></p>
<p><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="color: #000000;">
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">DataItem</span><br />{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">string</span> Key;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">string</span> Value;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">public</span> DataItem(<span style="color: blue;">string</span> key, <span style="color: blue;">string</span> value)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Key = key;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Value = value;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;</p>
</span></span></span>&nbsp; <span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">Now we will use the </span></span><a target="_blank" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/System.Generics.List" title="https://msdn.microsoft.com/en-us/library/6sh2ey19.aspx"><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">System.Generics.List</span></span></a><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">&nbsp;&nbsp;to <em>mimic </em>the dictionary or hashtable classes:</span></span>&nbsp;</p>
<p><span style="font-family: Consolas; color: #2b91af; font-size: 9.5pt;"><span style="font-family: Consolas; color: #2b91af; font-size: 9.5pt;">
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; color: #2b91af; font-size: 9.5pt;">List</span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="color: #000000;">&lt;</span><span style="color: #2b91af;">DataItem</span><span style="color: #000000;">&gt; tempdataitems = </span><span style="color: blue;">new</span><span style="color: #000000;"> </span><span style="color: #2b91af;">List</span><span style="color: #000000;">&lt;</span><span style="color: #2b91af;">DataItem</span><span style="color: #000000;">&gt;(myDictionary.Count);<o:p></o:p></span></span></p>
</span></span></p>
<p>&nbsp;&nbsp; <span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">Since this is now serializable, we can jjust foreach through our Dictionary or Hashtable objects and build&nbsp;our tempdataitmes class to serialize.</span></span></p>
<p><span style="font-family: Consolas; font-size: 9.5pt;">
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">foreach</span><span style="font-family: Consolas; font-size: 9.5pt;"> (<span style="color: blue;">string</span> key <span style="color: blue;">in</span> myDictionary.Keys)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>tempdataitems.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">DataItem</span>(key, myDictionary[key].ToString()));<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;</p>
</span>&nbsp;&nbsp; <span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">The last thing I need to do is serialize this to a string so I can now store it in my SQL database with the column type of XML.</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">private</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span> SerializeJobData()<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: #2b91af;">List</span>&lt;<span style="color: #2b91af;">DataItem</span>&gt; tempdataitems = <span style="color: blue;">new</span> <span style="color: #2b91af;">List</span>&lt;<span style="color: #2b91af;">DataItem</span>&gt;(myDictionary.Count);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">foreach</span> (<span style="color: blue;">string</span> key <span style="color: blue;">in</span> dataitems.Keys)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>tempdataitems.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">DataItem</span>(key, dataitems[key].ToString()));<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: #2b91af;">XmlSerializer</span> serializer = <span style="color: blue;">new</span> <span style="color: #2b91af;">XmlSerializer</span>(<span style="color: blue;">typeof</span>(<span style="color: #2b91af;">List</span>&lt;<span style="color: #2b91af;">DataItem</span>&gt;));<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: #2b91af;">StringWriter</span> sw = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringWriter</span>();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: #2b91af;">XmlSerializerNamespaces</span> ns = <span style="color: blue;">new</span> <span style="color: #2b91af;">XmlSerializerNamespaces</span>();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>ns.Add(<span style="color: #a31515;">""</span>,<span style="color: #a31515;">""</span>);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>serializer.Serialize(sw, tempdataitems,ns);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">return</span> sw.ToString();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></p>
<p>
<p>&nbsp;&nbsp; <span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">In this example I am using the .net 4 </span></span><a target="_blank" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/StringWriter" title="https://msdn.microsoft.com/en-us/library/system.io.stringwriter.aspx"><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">StringWriter</span></span></a><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;"> class from the System.IO namespace. This makes working with the stream needed for xml serialization simple because it hanldes the stream needed for xml serialization. In addtion you can see that I didn't want the default .net namespace in my xml so I set&nbsp;the namespace of the xmlsericalizer &nbsp;to "". If you want more control over your xml be sure to include your custom namespace.</span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">&nbsp;&nbsp; Here's what the data looks like in SQL:</span></span></p>
</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">ArrayOfDataItem</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">DataItem</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">Key</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;">Vera<span style="color: blue;">&lt;/</span><span style="color: #a31515;">Key</span><span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">Value</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;">Vera<span style="color: blue;">&lt;/</span><span style="color: #a31515;">Value</span><span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">DataItem</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">DataItem</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">Key</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;">David<span style="color: blue;">&lt;/</span><span style="color: #a31515;">Key</span><span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">Value</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;">David<span style="color: blue;">&lt;/</span><span style="color: #a31515;">Value</span><span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">DataItem</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">DataItem</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">Key</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;">Susan<span style="color: blue;">&lt;/</span><span style="color: #a31515;">Key</span><span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">Value</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;">Susan<span style="color: blue;">&lt;/</span><span style="color: #a31515;">Value</span><span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">DataItem</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">DataItem</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">Key</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;">FakeParam<span style="color: blue;">&lt;/</span><span style="color: #a31515;">Key</span><span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">Value</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;">FakeParam<span style="color: blue;">&lt;/</span><span style="color: #a31515;">Value</span><span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">DataItem</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&lt;/</span><span style="font-family: 'Courier New'; color: #a31515; font-size: 10pt; mso-no-proof: yes;">ArrayOfDataItem</span><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">&gt;</span>&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">&nbsp;&nbsp; As you can see this is nice and clean. </span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">&nbsp;&nbsp; The last thing we would need to tacke is deserializing back to a Dictionary&lt;string, string&gt; object. I'm going to again use the StringWriter class to help me.</span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">private</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">void</span> DeserializeData(<span style="color: blue;">string</span> RawData)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; color: #2b91af; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>Dictionary</span><span style="font-family: Consolas; font-size: 9.5pt;">&lt;<span style="color: blue;">string</span>, <span style="color: blue;">string</span>&gt; myDictionary = <span style="color: blue;">new</span> <span style="color: #2b91af;">Dictionary</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">string</span>&gt;();<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;</span><span style="mso-spacerun: yes;">&nbsp; </span><span style="color: #2b91af;">XmlSerializer</span> xs = <span style="color: blue;">new</span> <span style="color: #2b91af;">XmlSerializer</span>(<span style="color: blue;">typeof</span>(<span style="color: #2b91af;">List</span>&lt;<span style="color: #2b91af;">DataItem</span>&gt;));<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;</span><span style="mso-spacerun: yes;">&nbsp;</span><span style="mso-spacerun: yes;">&nbsp;</span><span style="color: #2b91af;">StringReader</span> sr = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringReader</span>(RawData);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: #2b91af;">List</span>&lt;<span style="color: #2b91af;">DataItem</span>&gt; templist = (<span style="color: #2b91af;">List</span>&lt;<span style="color: #2b91af;">DataItem</span>&gt;)xs.Deserialize(sr);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">foreach</span> (<span style="color: #2b91af;">DataItem</span> di <span style="color: blue;">in</span> templist)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>myDictionary.Add(di.Key, di.Value);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #c3c8cf; mso-layout-grid-align: none;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></p>
<p class="MsoNormal">
<p>
<p>&nbsp;&nbsp; <span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">Super simple! </span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;">&nbsp;&nbsp; I hope this helps you quicly get through this task and answers all questions regarding serializing and deserialize the .net 4 Dictionary and Hashtable classes</span></span>.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</p>
<p>&nbsp;</p>
</p>]]></content:encoded>
    </item>
    <item>
      <title>How to get Job progress from SCVMM</title>
      <link>https://docs.microsoft.com/archive/blogs/adam/how-to-get-job-progress-from-scvmm</link>
      <pubDate>Mon, 09 Aug 2010 11:54:00 GMT</pubDate>
      <dc:creator><![CDATA[Bambam9876]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/adam/2010/08/09/how-to-get-job-progress-from-scvmm/</guid>
      <description><![CDATA[Hey guys,
&nbsp;&nbsp; In this post I will discuss a question that has come my way a few times....]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';">Hey guys,<br style="mso-special-character: line-break;" /><br style="mso-special-character: line-break;" /><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';">&nbsp;&nbsp; In this post I will discuss a question that has come my way a few times. This post will discuss how to get the percentage of a job task from SCVMM that you may use in your custom applications to allow your end users to watch the progress of a task performed on a VM being managed by SCVMM. This post will assume you are familiar with programming against SCVMM via both powershell and C#. If you are not familiar with these concepts, please review my previous blog posts to get started.<br style="mso-special-character: line-break;" /><br style="mso-special-character: line-break;" /><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';">&nbsp;&nbsp; I will not delve into the understanding of the SCVMM tables stored in SQL. I wll highlight which tables contain the information we need to perform our desired task.<b> Please note, that any modifcation to the SCVMM database (default name VirtualManagerDB) is unsupported. Any modifications to this database may break your existing SCVMM setup, and Microsoft may not assist you with recovery of this data, as modifications to this database are unsupported</b>.<br style="mso-special-character: line-break;" /><br style="mso-special-character: line-break;" /><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';">&nbsp;&nbsp; The first table we will need to look is the "<b>tbl_WLC_VObject table</b>". This tables contains base information for SCVMM objects (VMs, Templates, etc). You can differentiate the different objects by their object type found in this table. For example, <span style="background: white;">object</span>type "1" is a virtual machine, object type "3' is a template. The field we're going after is the "FailedJobID" field. This field will either contain a NULL value or a GUID. We will need this GUID to look up the progress status. There are tons of different ways you may wish to filter for this GUID, but to keep it simple, I'll just go with:<br style="mso-special-character: line-break;" /><br style="mso-special-character: line-break;" /><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">SELECT</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;"> [FailedJobID]<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp; </span><span style="color: blue;">FROM</span> [VirtualManagerDB]<span style="color: gray;">.</span>[dbo]<span style="color: gray;">.</span>[tbl_WLC_VObject]<o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt; background: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217;"><span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp; </span><span style="color: blue;">WHERE</span> ObjectType <span style="color: gray;">=</span> 1 <span style="color: gray;">AND</span> Name <span style="color: gray;">=</span> <span style="color: red;">'MyGreatVM'<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: 'Arial','sans-serif'; background: white; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';">&nbsp;&nbsp; <br /><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>So far so good. We now have a GUID to represent the JobID for the job in question. From this point on I will refer to this GUID as JobID.<br style="mso-special-character: line-break;" /><br style="mso-special-character: line-break;" /></span><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: 'Arial','sans-serif'; background: white; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';">&nbsp;&nbsp; The last thing we will need to do is query the table called "<b>tbl_TR_SubtaskTrail</b>" to get our completion status. Remember that this will continuously change as the status progresses so you will want to keep comming back and checking this table until your task is done. Here's what we will use:<br style="mso-special-character: line-break;" /><br style="mso-special-character: line-break;" /></span><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: 'Arial','sans-serif'; background: white; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';">&nbsp;&nbsp;&nbsp; I've added a bit more logic in my query to insure that I am targetting a task description of "NewVM". In this example, we will assume that we are going to get progress status for&nbsp;a new VM that is building. The addition of the Description ='NewVM'&nbsp; feild insures that I only get progress for this particular task (the New VM build task).<br style="mso-special-character: line-break;" /><br style="mso-special-character: line-break;" /></span><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">SELECT</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;"> PercentComplete<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">FROM</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;"> tbl_TR_SubtaskTrail<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; background: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none;"><span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes;">WHERE</span><span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;"> tbl_TR_SubtaskTrail<span style="color: gray;">.</span>TaskID <span style="color: gray;">=</span> @JobID<o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt; background: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217;"><span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt; mso-no-proof: yes;">AND</span><span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes;"> <span style="color: blue;">Description</span> <span style="color: gray;">=</span> <span style="color: red;">'NewVM'<o:p></o:p></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: 'Arial','sans-serif'; background: white; color: black; font-size: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman';">&nbsp;&nbsp; <br /><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span></span><span style="font-family: 'Arial','sans-serif'; background: white; color: black; font-size: 9pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman';">That's it, you can now use this display data wherever you like to keep you clients informed of the percentage complete of a task in SCVMM. I have also showed how to give a little extra insurance that you are tracking the task that you are looking for by using an extra WHERE clause against the Description field.</span><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';"> <br style="mso-special-character: line-break;" /><br style="mso-special-character: line-break;" /><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: 'Arial','sans-serif'; background: white; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';">&nbsp;&nbsp; In reality you will probably not&nbsp;want to call this SQL statement from code in a loop unitl you hit 100 percent. You will want to instead create a stored procedure instead in SQL and call that stored procedure with a parameter value of JobID. This is the least expensive way to get the data, and allows SQL to&nbsp;do it's job (which is all the work).<br style="mso-special-character: line-break;" /><br style="mso-special-character: line-break;" /></span><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: 'Arial','sans-serif'; background: white; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';">&nbsp;&nbsp; As always enjoy!</span><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman';"><o:p></o:p></span></p>
<p><span style="line-height: 115%; font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">&nbsp;</span></p>]]></content:encoded>
    </item>
    <item>
      <title>Getting a thumbnail from Hyper-V or SCVMM in C#</title>
      <link>https://docs.microsoft.com/archive/blogs/adam/getting-a-thumbnail-from-hyper-v-or-scvmm-in-c</link>
      <pubDate>Tue, 13 Apr 2010 07:08:00 GMT</pubDate>
      <dc:creator><![CDATA[Bambam9876]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/adam/2010/04/13/getting-a-thumbnail-from-hyper-v-or-scvmm-in-c/</guid>
      <description><![CDATA[&nbsp;&nbsp; This blog post will discuss how to get a thumbnail from Hyper-V. I will show you how to...]]></description>
      <content:encoded><![CDATA[<P>&nbsp;&nbsp; This blog post will discuss how to get a thumbnail from Hyper-V. I will show you how to set the size for the thumbnail and save the thumbnail as a usable image file. In this example I will be saving the thumbnail image as a .jpg. There are other blog posts that discuss how to get the thumbnail, and posts on how to work with the System.Management classes to save the thumbnail, but this post will put the parts together in it's entirety and demonstrate how to get the thumbnail as a usable image in C#.<BR><BR>&nbsp;&nbsp;&nbsp; I've used some code from Taylor Brown's Blog post and such I want to give him due credit. His blogs in my opinion are cutting edge for working with SCVMM via code and have proven invaluable to me in my SCVMM development projects. The post I am referencing can be found here:</P>
<P><A href="https://blogs.msdn.com/taylorb/archive/2008/07/29/hyper-v-wmi-creating-a-thumbnail-image.aspx" mce_href="https://blogs.msdn.com/taylorb/archive/2008/07/29/hyper-v-wmi-creating-a-thumbnail-image.aspx">https://blogs.msdn.com/taylorb/archive/2008/07/29/hyper-v-wmi-creating-a-thumbnail-image.aspx</A></P>
<P>&nbsp;&nbsp;&nbsp; Let's talk about a few things with&nbsp;my blog&nbsp;post. First you can call into SCVMM to get thumbnails. </P>
<P>&nbsp;&nbsp;&nbsp; We could call into SCVMM and get a thumbnail in powershell but I find that the performance is not nearly as fast as calling directly into Hyper-V. Performance for me is paramount because I am going to be refreshing my thumbnails often. I also prefer not to have to queue many SCVMM cmdlets, I need SCVMM available and ready to service my VMs for actions such as Stop-VM or Remove-VM. Instead I am going to call directly into Hyper-V via WMI calls. Use WMI calls with caution, and you should be comfortable and have a working understanding of WMI calls to fully understand this blog post.</P>
<P>&nbsp;&nbsp;&nbsp; The function I am going to write, GetThumbnailForVM takes two parameters:</P>
<P>&nbsp;&nbsp;&nbsp; <STRONG>vmName</STRONG> - string which is the name of the VM we want to get the thumbnail for.<BR><BR>&nbsp;&nbsp;&nbsp; <STRONG>vmHost</STRONG> - string which tells us what host the VM lives on</P>
<P>&nbsp;&nbsp;&nbsp; You could dynamically get the vmHost by calling:</P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">Get-VM <I style="mso-bidi-font-style: normal">[vmName]</I>| select VMHost</SPAN></P><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'"><FONT color=#000000 face=Arial>
<P>&nbsp;&nbsp;&nbsp;&nbsp; You could then simply your function to only need vmName. </P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; For more information on creating functions that call into SCVMM from C# and getting these return values to use in your code,&nbsp;see my earlier blog posts.</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; One last note. If the VM in question is stopped, then you will get a blank screen returned as your image. Makes sense; since there is nothing to return. To keep your program clean you may wish to check the status of the vm, if it is stopped, return an image that gives the user some insight that the VM is in a stopped state. I'll implement this in my code sample to show you how to do this.</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; Let's take a look at the GetThumbnailforVM function:</P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">public</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">bool</SPAN> GetThumbnailForVM(<SPAN style="COLOR: blue">string</SPAN> vmName, <SPAN style="COLOR: blue">string</SPAN> vmHost)<?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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (vmName.Status == <SPAN style="COLOR: #a31515">"Stopped"</SPAN>)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">string</SPAN> stopinmage = path + <SPAN style="COLOR: #a31515">"Images\\Icons\\poweroff.jpg"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">string</SPAN> copyimage = path + <SPAN style="COLOR: #a31515">"Thumbnails\\"</SPAN> + vmName + <SPAN style="COLOR: #a31515">".jpg"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">File</SPAN>.Delete(copyimage);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">File</SPAN>.Copy(stopinmage, copyimage);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">Thumbnail</SPAN> thumbnail = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">Thumbnail</SPAN>();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>thumbnail.GetVirtualSystemThumbnailImage(vmName, vmHost);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}</SPAN><o:p></o:p></P>
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp; Pretty straight forward. I am assuming here that path is something relevant to you. The "<EM>path</EM>" variable will be set by you referring to where you want to store your VM thumbnails. In this function if the status is stopped, I then go and grab an image I call "poweroff.jpg" and store that image in our path. Since we don't need to get a real thumbnail, I return out of the function here. When I save the thumbnail image, I save it using <EM>[vmName]</EM>.jpg.</P>
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp; If the VM is not stopped, then I create a new Thumbnail class and call the GetVirtualSystemThumbnailImage method on the Thumbnail&nbsp;class.</P>
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp; Here is the listing for the Thumbnail class. I will break down the things in this class after this listing:</P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">public</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">Thumbnail<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>static</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">int</SPAN> x = 320, y = 240;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">void</SPAN> GetVirtualSystemThumbnailImage(<SPAN style="COLOR: blue">string</SPAN> vmName, <SPAN style="COLOR: blue">string</SPAN> host)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">ManagementScope</SPAN> scope = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ManagementScope</SPAN>(<SPAN style="COLOR: #a31515">@"\\"</SPAN> + host + <SPAN style="COLOR: #a31515">@"\root\virtualization"</SPAN>, <SPAN style="COLOR: blue">null</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">ManagementObject</SPAN> virtualSystemService = <SPAN style="COLOR: #2b91af">Utility</SPAN>.GetServiceObject(scope, <SPAN style="COLOR: #a31515">"Msvm_VirtualSystemManagementService"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">ManagementObject</SPAN> vm = <SPAN style="COLOR: #2b91af">Utility</SPAN>.GetTargetComputer(vmName, scope);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">ManagementObjectCollection</SPAN> vmsettingDatas = vm.GetRelated(<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #a31515">"Msvm_VirtualSystemsettingData"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #a31515">"Msvm_SettingsDefineState"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">null</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">null</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #a31515">"SettingData"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #a31515">"ManagedElement"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">false</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">null</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">ManagementObject</SPAN> settingData = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">foreach</SPAN> (<SPAN style="COLOR: #2b91af">ManagementObject</SPAN> data <SPAN style="COLOR: blue">in</SPAN> vmsettingDatas)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;</SPAN>settingData = data;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">break</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #2b91af">ManagementBaseObject</SPAN> inParams = virtualSystemService.GetMethodParameters(<SPAN style="COLOR: #a31515">"GetVirtualSystemThumbnailImage"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>inParams[<SPAN style="COLOR: #a31515">"HeightPixels"</SPAN>] = 240;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>inParams[<SPAN style="COLOR: #a31515">"WidthPixels"</SPAN>] = 320;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>inParams[<SPAN style="COLOR: #a31515">"TargetSystem"</SPAN>] = settingData.Path.Path;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">ManagementBaseObject</SPAN> outParams = virtualSystemService.InvokeMethod(<SPAN style="COLOR: #a31515">"GetVirtualSystemThumbnailImage"</SPAN>, inParams, <SPAN style="COLOR: blue">null</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> ((<SPAN style="COLOR: #2b91af">UInt32</SPAN>)outParams[<SPAN style="COLOR: #a31515">"ReturnValue"</SPAN>] == <SPAN style="COLOR: #2b91af">ReturnCode</SPAN>.Started)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: #2b91af">Utility</SPAN>.JobCompleted(outParams, scope))<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>SaveImageData((<SPAN style="COLOR: blue">byte</SPAN>[])outParams[<SPAN style="COLOR: #a31515">"ImageData"</SPAN>], vmName);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">else<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: green">// Something went wrong with the creation<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="COLOR: blue">else</SPAN> <SPAN style="COLOR: blue">if</SPAN> ((<SPAN style="COLOR: #2b91af">UInt32</SPAN>)outParams[<SPAN style="COLOR: #a31515">"ReturnValue"</SPAN>] == <SPAN style="COLOR: #2b91af">ReturnCode</SPAN>.Completed)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>SaveImageData((<SPAN style="COLOR: blue">byte</SPAN>[])outParams[<SPAN style="COLOR: #a31515">"ImageData"</SPAN>], vmName);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">else<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">// Something went wrong with the creation<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//ErrorEventArgs =(UInt32)outParams["ReturnValue"]<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>inParams.Dispose();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>outParams.Dispose();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>settingData.Dispose();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>vm.Dispose();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>virtualSystemService.Dispose();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>static</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">void</SPAN> SaveImageData(<SPAN style="COLOR: blue">byte</SPAN>[] imageData, <SPAN style="COLOR: blue">string</SPAN> vmName)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>path += <SPAN style="COLOR: #a31515">@"\Thumbnails\"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">Bitmap</SPAN> VMThumbnail = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">Bitmap</SPAN>(x, y, <SPAN style="COLOR: #2b91af">PixelFormat</SPAN>.Format16bppRgb565);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">Rectangle</SPAN> rectangle = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">Rectangle</SPAN>(0, 0, x, y);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">BitmapData</SPAN> VMThumbnailBiltmapData = VMThumbnail.LockBits(rectangle, <SPAN style="COLOR: #2b91af">ImageLockMode</SPAN>.WriteOnly, <SPAN style="COLOR: #2b91af">PixelFormat</SPAN>.Format16bppRgb565);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>System.Runtime.InteropServices.<SPAN style="COLOR: #2b91af">Marshal</SPAN>.Copy(imageData, 0, VMThumbnailBiltmapData.Scan0, x * y * 2);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>VMThumbnail.UnlockBits(VMThumbnailBiltmapData);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>VMThumbnail.Save(path + vmName + <SPAN style="COLOR: #a31515">".jpg"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}</SPAN><o:p></o:p></P>
<P mce_keep="true">
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp; We will need to add a reference to the System.Management .dll. We will also need to add using statements for the following namespaces:</P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">using</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> System.Management;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">using</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> System.Drawing;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">using</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> System.IO;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">using</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> System.Drawing.Imaging;</SPAN><o:p></o:p></P>
<P mce_keep="true">
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp; The first area we will look at is the two integers <EM>x </EM>and <EM>y</EM>. These numbers represent the size in pixels that we want our thumbnail image to displayed in. You can see that I create a image based on the hard coded values 240 x 320. If you wish, you can make this dyncamic and change these static integers to be properties of the Thumbnail class, so&nbsp;that you can set the size&nbsp;when you instantiate your Thumbnail class. </P>
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp; There are only two methods of this class:</P>
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <STRONG>GetVirtualSystemThumbnailImage</STRONG> - taking in the values from earlier, a string for the vmName and a string for the VMhost the VM lives on.</P>
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <STRONG>SaveImageData</STRONG> - this is a private method that we use in the GetVirtualSystemThumbnailImage method to save our image data.</P>
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp; When we called our original function we already had the path of where we want to strore the images defined. This path is used again in the SaveImageData function. We do append the path with "<EM>\Thumbnails\</EM>" for our store just to make final findings eaiser. As mentioned earlier, you may wish to make this dynamic as well. For that I would simply add a public property to the Thumbnail class that accepts a string value of the path you wish to use.</P>
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp; There is one other class that we use in the GetVirtualSystemThumbnailImage function. I did not write this classl, and thus I will not be going into detail about this class. The class is documented in the following MSDN topic:</P>
<P mce_keep="true">Common Utilities for the Virtualization Samples<BR><A href="https://msdn.microsoft.com/en-us/library/cc723869(VS.85).aspx">https://msdn.microsoft.com/en-us/library/cc723869(VS.85).aspx</A></P>
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp; I will add this class defintion to the bottom of this post, in case this link ever changes.</P>
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I hope this saves you some time, and as always enjoy!</P>
<P mce_keep="true">&nbsp;</P>
<P mce_keep="true">&nbsp;</P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">static</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">ResourceType<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> Other = 1;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> ComputerSystem = 2;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> Processor = 3;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> Memory = 4;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> IDEController = 5;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> ParallelSCSIHBA = 6;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> FCHBA = 7;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> iSCSIHBA = 8;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> IBHCA = 9;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> EthernetAdapter = 10;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> OtherNetworkAdapter = 11;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> IOSlot = 12;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> IODevice = 13;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> FloppyDrive = 14;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> CDDrive = 15;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> DVDdrive = 16;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> Serialport = 17;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> Parallelport = 18;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> USBController = 19;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> GraphicsController = 20;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> StorageExtent = 21;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> Disk = 22;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> Tape = 23;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> OtherStorageDevice = 24;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> FirewireController = 25;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> PartitionableUnit = 26;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> BasePartitionableUnit = 27;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> PowerSupply = 28;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> CoolingDevice = 29;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> DisketteController = 1;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">ResourceSubType<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> DisketteController = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> DisketteDrive = <SPAN style="COLOR: #a31515">"Microsoft Synthetic Diskette Drive"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> ParallelSCSIHBA = <SPAN style="COLOR: #a31515">"Microsoft Synthetic SCSI Controller"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: blue">string</SPAN> IDEController = <SPAN style="COLOR: #a31515">"Microsoft Emulated IDE Controller"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> DiskSynthetic = <SPAN style="COLOR: #a31515">"Microsoft Synthetic Disk Drive"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> DiskPhysical = <SPAN style="COLOR: #a31515">"Microsoft Physical Disk Drive"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> DVDPhysical = <SPAN style="COLOR: #a31515">"Microsoft Physical DVD Drive"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> DVDSynthetic = <SPAN style="COLOR: #a31515">"Microsoft Synthetic DVD Drive"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> CDROMPhysical = <SPAN style="COLOR: #a31515">"Microsoft Physical CD Drive"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> CDROMSynthetic = <SPAN style="COLOR: #a31515">"Microsoft Synthetic CD Drive"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> EthernetSynthetic = <SPAN style="COLOR: #a31515">"Microsoft Synthetic Ethernet Port"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//logical drive<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> DVDLogical = <SPAN style="COLOR: #a31515">"Microsoft Virtual CD/DVD Disk"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> ISOImage = <SPAN style="COLOR: #a31515">"Microsoft ISO Image"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> VHD = <SPAN style="COLOR: #a31515">"Microsoft Virtual Hard Disk"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> DVD = <SPAN style="COLOR: #a31515">"Microsoft Virtual DVD Disk"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> VFD = <SPAN style="COLOR: #a31515">"Microsoft Virtual Floppy Disk"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> videoSynthetic = <SPAN style="COLOR: #a31515">"Microsoft Synthetic Display Controller"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">OtherResourceType<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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: blue">string</SPAN> DisketteController = <SPAN style="COLOR: #a31515">"Microsoft Virtual Diskette Controller"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">ReturnCode<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> Completed = 0;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> Started = 4096;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> Failed = 32768;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> AccessDenied = 32769;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> NotSupported = 32770;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> Unknown = 32771;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt32</SPAN> Timeout = 32772;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> InvalidParameter = 32773;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> SystemInUser = 32774;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> InvalidState = 32775;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> IncorrectDataType = 32776;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> SystemNotAvailable = 32777;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> OutofMemory = 32778;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">Utility<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">JobState<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt16</SPAN> New = 2;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt16</SPAN> Starting = 3;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt16</SPAN> Running = 4;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt16</SPAN> Suspened = 5;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt16</SPAN> ShuttingDown = 6;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt16</SPAN> Completed = 7;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt16</SPAN> Terminated = 8;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt16</SPAN> Killed = 9;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt16</SPAN> Exception = 10;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">public</SPAN> <SPAN style="COLOR: blue">const</SPAN> <SPAN style="COLOR: #2b91af">UInt16</SPAN> Service = 11;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Common utility function to get a service oject<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;param name="scope"&gt;&lt;/param&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;param name="serviceName"&gt;&lt;/param&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> GetServiceObject(<SPAN style="COLOR: #2b91af">ManagementScope</SPAN> scope, <SPAN style="COLOR: blue">string</SPAN> serviceName)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>scope.Connect();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #2b91af">ManagementPath</SPAN> wmiPath = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ManagementPath</SPAN>(serviceName);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementClass</SPAN> serviceClass = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ManagementClass</SPAN>(scope, wmiPath, <SPAN style="COLOR: blue">null</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObjectCollection</SPAN> services = serviceClass.GetInstances();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> serviceObject = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">foreach</SPAN> (<SPAN style="COLOR: #2b91af">ManagementObject</SPAN> service <SPAN style="COLOR: blue">in</SPAN> services)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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>serviceObject = service;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> serviceObject;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> GetHostSystemDevice(<SPAN style="COLOR: blue">string</SPAN> deviceClassName, <SPAN style="COLOR: blue">string</SPAN> deviceObjectElementName, <SPAN style="COLOR: #2b91af">ManagementScope</SPAN> scope)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> hostName = System.<SPAN style="COLOR: #2b91af">Environment</SPAN>.MachineName;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> systemDevice = GetSystemDevice(deviceClassName, deviceObjectElementName, hostName, scope);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> systemDevice;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> GetSystemDevice<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> deviceClassName,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> deviceObjectElementName,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> vmName,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementScope</SPAN> scope)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> systemDevice = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> computerSystem = <SPAN style="COLOR: #2b91af">Utility</SPAN>.GetTargetComputer(vmName, scope);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObjectCollection</SPAN> systemDevices = computerSystem.GetRelated<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>deviceClassName,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #a31515">"Msvm_SystemDevice"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">null</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">null</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #a31515">"PartComponent"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #a31515">"GroupComponent"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">false</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">null<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">foreach</SPAN> (<SPAN style="COLOR: #2b91af">ManagementObject</SPAN> device <SPAN style="COLOR: blue">in</SPAN> systemDevices)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">if</SPAN> (device[<SPAN style="COLOR: #a31515">"ElementName"</SPAN>].ToString().ToLower() == deviceObjectElementName.ToLower())<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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>systemDevice = device;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">break</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> systemDevice;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">bool</SPAN> JobCompleted(<SPAN style="COLOR: #2b91af">ManagementBaseObject</SPAN> outParams, <SPAN style="COLOR: #2b91af">ManagementScope</SPAN> scope)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">bool</SPAN> jobCompleted = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">//Retrieve msvc_StorageJob path. This is a full wmi path<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> JobPath = (<SPAN style="COLOR: blue">string</SPAN>)outParams[<SPAN style="COLOR: #a31515">"Job"</SPAN>];<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> Job = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ManagementObject</SPAN>(scope, <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ManagementPath</SPAN>(JobPath), <SPAN style="COLOR: blue">null</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">//Try to get storage job information<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Job.Get();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">while</SPAN> ((<SPAN style="COLOR: #2b91af">UInt16</SPAN>)Job[<SPAN style="COLOR: #a31515">"JobState"</SPAN>] == <SPAN style="COLOR: #2b91af">JobState</SPAN>.Starting<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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>|| (<SPAN style="COLOR: #2b91af">UInt16</SPAN>)Job[<SPAN style="COLOR: #a31515">"JobState"</SPAN>] == <SPAN style="COLOR: #2b91af">JobState</SPAN>.Running)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #2b91af">Console</SPAN>.WriteLine(<SPAN style="COLOR: #a31515">"In progress... {0}% completed."</SPAN>, Job[<SPAN style="COLOR: #a31515">"PercentComplete"</SPAN>]);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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>System.Threading.<SPAN style="COLOR: #2b91af">Thread</SPAN>.Sleep(1000);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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>Job.Get();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">//Figure out if job failed<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> jobState = (<SPAN style="COLOR: #2b91af">UInt16</SPAN>)Job[<SPAN style="COLOR: #a31515">"JobState"</SPAN>];<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> (jobState != <SPAN style="COLOR: #2b91af">JobState</SPAN>.Completed)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">UInt16</SPAN> jobErrorCode = (<SPAN style="COLOR: #2b91af">UInt16</SPAN>)Job[<SPAN style="COLOR: #a31515">"ErrorCode"</SPAN>];<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #2b91af">Console</SPAN>.WriteLine(<SPAN style="COLOR: #a31515">"Error Code:{0}"</SPAN>, jobErrorCode);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #2b91af">Console</SPAN>.WriteLine(<SPAN style="COLOR: #a31515">"ErrorDescription: {0}"</SPAN>, (<SPAN style="COLOR: blue">string</SPAN>)Job[<SPAN style="COLOR: #a31515">"ErrorDescription"</SPAN>]);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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>jobCompleted = <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> jobCompleted;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> GetTargetComputer(<SPAN style="COLOR: blue">string</SPAN> vmElementName, <SPAN style="COLOR: #2b91af">ManagementScope</SPAN> scope)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> query = <SPAN style="COLOR: blue">string</SPAN>.Format(<SPAN style="COLOR: #a31515">"select * from Msvm_ComputerSystem Where ElementName = '{0}'"</SPAN>, vmElementName);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObjectSearcher</SPAN> searcher = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ManagementObjectSearcher</SPAN>(scope, <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ObjectQuery</SPAN>(query));<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObjectCollection</SPAN> computers = searcher.Get();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> computer = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">foreach</SPAN> (<SPAN style="COLOR: #2b91af">ManagementObject</SPAN> instance <SPAN style="COLOR: blue">in</SPAN> computers)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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>computer = instance;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">break</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> computer;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> GetVirtualSystemSettingData(<SPAN style="COLOR: #2b91af">ManagementObject</SPAN> vm)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> vmSetting = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObjectCollection</SPAN> vmSettings = vm.GetRelated<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #a31515">"Msvm_VirtualSystemSettingData"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #a31515">"Msvm_SettingsDefineState"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">null</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">null</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #a31515">"SettingData"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #a31515">"ManagedElement"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">false</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">null<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> (vmSettings.Count != 1)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">throw</SPAN> <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">Exception</SPAN>(<SPAN style="COLOR: #2b91af">String</SPAN>.Format(<SPAN style="COLOR: #a31515">"{0} instance of Msvm_VirtualSystemSettingData was found"</SPAN>, vmSettings.Count));<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">foreach</SPAN> (<SPAN style="COLOR: #2b91af">ManagementObject</SPAN> instance <SPAN style="COLOR: blue">in</SPAN> vmSettings)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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>vmSetting = instance;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">break</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> vmSetting;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">enum</SPAN> <SPAN style="COLOR: #2b91af">ValueRole<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Default = 0,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Minimum = 1,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Maximum = 2,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Increment = 3<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">enum</SPAN> <SPAN style="COLOR: #2b91af">ValueRange<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Default = 0,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Minimum = 1,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Maximum = 2,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Increment = 3<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">// Get RASD definitions<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> GetResourceAllocationsettingDataDefault<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementScope</SPAN> scope,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> resourceType,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> resourceSubType,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> otherResourceType<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> RASD = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> query = <SPAN style="COLOR: #2b91af">String</SPAN>.Format(<SPAN style="COLOR: #a31515">"select * from Msvm_ResourcePool where ResourceType = '{0}' and ResourceSubType ='{1}' and OtherResourceType = '{2}'"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>resourceType, resourceSubType, otherResourceType);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> (resourceType == <SPAN style="COLOR: #2b91af">ResourceType</SPAN>.Other)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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>query = <SPAN style="COLOR: #2b91af">String</SPAN>.Format(<SPAN style="COLOR: #a31515">"select * from Msvm_ResourcePool where ResourceType = '{0}' and ResourceSubType = null and OtherResourceType = {1}"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>resourceType, otherResourceType);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">else<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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>query = <SPAN style="COLOR: #2b91af">String</SPAN>.Format(<SPAN style="COLOR: #a31515">"select * from Msvm_ResourcePool where ResourceType = '{0}' and ResourceSubType ='{1}' and OtherResourceType = null"</SPAN>,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>resourceType, resourceSubType);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObjectSearcher</SPAN> searcher = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ManagementObjectSearcher</SPAN>(scope, <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ObjectQuery</SPAN>(query));<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObjectCollection</SPAN> poolResources = searcher.Get();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">//Get pool resource allocation ability<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> (poolResources.Count == 1)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">foreach</SPAN> (<SPAN style="COLOR: #2b91af">ManagementObject</SPAN> poolResource <SPAN style="COLOR: blue">in</SPAN> poolResources)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #2b91af">ManagementObjectCollection</SPAN> allocationCapabilities = poolResource.GetRelated(<SPAN style="COLOR: #a31515">"Msvm_AllocationCapabilities"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">foreach</SPAN> (<SPAN style="COLOR: #2b91af">ManagementObject</SPAN> allocationCapability <SPAN style="COLOR: blue">in</SPAN> allocationCapabilities)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">ManagementObjectCollection</SPAN> settingDatas = allocationCapability.GetRelationships(<SPAN style="COLOR: #a31515">"Msvm_SettingsDefineCapabilities"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">foreach</SPAN> (<SPAN style="COLOR: #2b91af">ManagementObject</SPAN> settingData <SPAN style="COLOR: blue">in</SPAN> settingDatas)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: #2b91af">Convert</SPAN>.ToInt16(settingData[<SPAN style="COLOR: #a31515">"ValueRole"</SPAN>]) == (<SPAN style="COLOR: #2b91af">UInt16</SPAN>)<SPAN style="COLOR: #2b91af">ValueRole</SPAN>.Default)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>RASD = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ManagementObject</SPAN>(settingData[<SPAN style="COLOR: #a31515">"PartComponent"</SPAN>].ToString());<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">break</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> RASD;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> GetResourceAllocationsettingData<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> vm,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">UInt16</SPAN> resourceType,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> resourceSubType,<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> otherResourceType<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">//vm-&gt;vmsettings-&gt;RASD for IDE controller<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObject</SPAN> RASD = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">ManagementObjectCollection</SPAN> settingDatas = vm.GetRelated(<SPAN style="COLOR: #a31515">"Msvm_VirtualSystemsettingData"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">foreach</SPAN> (<SPAN style="COLOR: #2b91af">ManagementObject</SPAN> settingData <SPAN style="COLOR: blue">in</SPAN> settingDatas)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: green">//retrieve the rasd<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #2b91af">ManagementObjectCollection</SPAN> RASDs = settingData.GetRelated(<SPAN style="COLOR: #a31515">"Msvm_ResourceAllocationsettingData"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">foreach</SPAN> (<SPAN style="COLOR: #2b91af">ManagementObject</SPAN> rasdInstance <SPAN style="COLOR: blue">in</SPAN> RASDs)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: #2b91af">Convert</SPAN>.ToUInt16(rasdInstance[<SPAN style="COLOR: #a31515">"ResourceType"</SPAN>]) == resourceType)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//found the matching type<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: blue">if</SPAN> (resourceType == <SPAN style="COLOR: #2b91af">ResourceType</SPAN>.Other)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (rasdInstance[<SPAN style="COLOR: #a31515">"OtherResourceType"</SPAN>].ToString() == otherResourceType)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>RASD = rasdInstance;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">break</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">else<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (rasdInstance[<SPAN style="COLOR: #a31515">"ResourceSubType"</SPAN>].ToString() == resourceSubType)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>RASD = rasdInstance;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">break</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> RASD;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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="MARGIN: 0in 0in 10pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}</SPAN><o:p></o:p></P>
<P mce_keep="true">&nbsp;</P></FONT></SPAN>]]></content:encoded>
    </item>
    <item>
      <title>Working with SCVMM Powershell in C# - InvokePowerShell function</title>
      <link>https://docs.microsoft.com/archive/blogs/adam/working-with-scvmm-powershell-in-c-invokepowershell-function</link>
      <pubDate>Fri, 26 Mar 2010 08:57:00 GMT</pubDate>
      <dc:creator><![CDATA[Bambam9876]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/adam/2010/03/26/working-with-scvmm-powershell-in-c-invokepowershell-function/</guid>
      <description><![CDATA[In may last post I used a function to allow C# to talk to SCVMM via powershell. This blog will...]]></description>
      <content:encoded><![CDATA[<P>In may last post I used a function to allow C# to talk to SCVMM via powershell. This blog will demonstrate and show you how to create your own InvokePowerShell functions, and I'll show you a way you can use this function with external powershell scripts so you can modify the powershell in your application without having to recompile the C# code.</P>
<P>In my applications, I&nbsp;use the InvokePowerShell function to call into SCVMM any time I need to work with any of the objects managed by SCVMM. My function will take a string parameter that contains the powershell I want to call. In my sample string you will see I add \r\n in my strings. This puts line breaks in the string&nbsp;so that when I debug, and I view my powershell in the Visual Studio debugger windows, the script is very easy to read (and check for errors!).</P>
<P mce_keep="true">The function will return a PSObject. This PSObject will return any errors if occurred, or if successful any information that would be normally seen in the powershell window. I show some examples of how to use this function as well.</P>
<P mce_keep="true">Before you can use this function, you will need to add a reference to the System.Management.Automation.dll. This is not so straight forwarded because this .dll is a little hard to find. Take a look at this article that will help you add this reference.</P>
<P mce_keep="true"><A href="https://www.codeplex.com/wikipage?ProjectName=ShinyPower&amp;title=Frequently%20Asked%20Questions" mce_href="https://www.codeplex.com/wikipage?ProjectName=ShinyPower&amp;title=Frequently%20Asked%20Questions">https://www.codeplex.com/wikipage?ProjectName=ShinyPower&amp;title=Frequently%20Asked%20Questions</A></P>
<P mce_keep="true">Here is link for reference on the System.Management.Automation namespace:</P>
<P mce_keep="true"><A href="https://msdn.microsoft.com/en-us/library/system.management.automation(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/system.management.automation(VS.85).aspx">https://msdn.microsoft.com/en-us/library/system.management.automation(VS.85).aspx</A></P>
<P mce_keep="true">OK.. let's take a look at the function:</P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">private</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: #2b91af">Collection</SPAN>&lt;<SPAN style="COLOR: #2b91af">PSObject</SPAN>&gt; InvokePowerShell(<SPAN style="COLOR: blue">string</SPAN> psscript)<?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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes">RunspaceConfiguration</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> rconfig = <SPAN style="COLOR: #2b91af">RunspaceConfiguration</SPAN>.Create();<SPAN style="COLOR: #2b91af">PSSnapInException</SPAN> Pwarn = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">PSSnapInException</SPAN>();<BR><BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>rconfig.AddPSSnapIn(<SPAN style="COLOR: #a31515">"Microsoft.SystemCenter.VirtualMachineManager"</SPAN>, <SPAN style="COLOR: blue">out</SPAN> Pwarn);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">Runspace</SPAN> runspace = <SPAN style="COLOR: #2b91af">RunspaceFactory</SPAN>.CreateRunspace(rconfig);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>runspace.Open();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">Pipeline</SPAN> pipeline = runspace.CreatePipeline();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>pipeline.Commands.AddScript(psscript);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">Collection</SPAN>&lt;<SPAN style="COLOR: #2b91af">PSObject</SPAN>&gt; results = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">Collection</SPAN>&lt;<SPAN style="COLOR: #2b91af">PSObject</SPAN>&gt;();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">try<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>results = pipeline.Invoke();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<BR style="mso-special-character: line-break"><BR style="mso-special-character: line-break"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">catch</SPAN>(<SPAN style="COLOR: #2b91af">Exception</SPAN> ex)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<BR></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; finally<BR></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>runspace.Close();<BR></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>runspace.Dispose();<BR></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<BR>}</SPAN></P><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>OK so now we have a function to call our powershell scripts. You will have to check and handle your exceptions yourself. <STRONG>Do not leave the try-catch like this as you will miss uhandled exceptions.&nbsp; </STRONG></FONT></o:p></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>There is one issue you have to be very careful with with this function. If this function is run in&nbsp;a process, and multiple calls to Get-VMMSerrver are called, a connection for each call will be held in the process until the process is taken down. The runspace Close and Dispose call do not clear these out. Avoid calling the generic Get-VMMServer cmdlet with this function. If you must use this cmdlet, make sure that it is only called once, and store a way to check with it with&nbsp;a static variable in your code.</FONT></o:p></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>Let's take a look at using the InvokePoweShell function. I'll use this function to&nbsp;take a SCVMM host out of placement. I will pass into this function a string for the host name, and a boolean value to set the host available and not available.&nbsp; The function will return true, if it succeeds and false if there is a problem:</FONT></o:p></P><o:p><FONT size=3 face=Calibri>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">public</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">bool</SPAN> SetHostAvailabeForPlacement(<SPAN style="COLOR: blue">string</SPAN> HostName, <SPAN style="COLOR: blue">boolean</SPAN> val)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">bool</SPAN> retval = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> psscript = <SPAN style="COLOR: #a31515">"$MyHost = Get-VMHost -VMMServer&nbsp;localhost</SPAN><SPAN style="COLOR: #a31515"> -ComputerName '"</SPAN> + HostName + <SPAN style="COLOR: #a31515">"'\r\n Set-VMHost -VMHost $MyHost -AvailableForPlacement $"</SPAN> + val;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">try<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: #2b91af">Collection</SPAN>&lt;<SPAN style="COLOR: #2b91af">PSObject</SPAN>&gt; results = InvokePowerShell(psscript);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">catch<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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> retval;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</SPAN><o:p></o:p></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal>You will notice that in my powershell script, I didn't use the Get-VMMServer function instead I just told the cmdlet which server to use. I also could have made this powershell a little cleaner by making the cmdlet call in one line:</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><FONT size=2><FONT face="Courier New"><SPAN style="COLOR: blue">string</SPAN> psscript = <SPAN style="COLOR: #a31515">"$MyHost = Get-VMHost -VMMServer&nbsp;localhost</SPAN><SPAN style="COLOR: #a31515"> -ComputerName '"</SPAN> + HostName + <SPAN style="COLOR: #a31515">"' | Set-VMHost&nbsp;-AvailableForPlacement $"</SPAN> + val;</FONT></FONT></P>In this example I'm not looking for any data back so I don't check the results PSObject. See my other blog posts for examples of this. 
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal>The last thing I want to demonstrate in this blog is how to use powershell that can be called from C# where you don't need to recompile your code to change the powershell. What I do is read the contents of an external text file into a string. I then parse that string replacing place holders with the values that I need. </P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">public</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">void</SPAN> CallPSFromFile(<SPAN style="COLOR: blue">string</SPAN> FileName)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">{ <o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">StreamReader</SPAN> sr = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">StreamReader</SPAN>(FileName);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> psscript = sr.ReadToEnd();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>sr.Close();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">string</SPAN> VMName = <SPAN style="COLOR: #a31515">"MyTestVM"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>psscript.Replace(<SPAN style="COLOR: #a31515">"__VMName__"</SPAN>, VMName);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; 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">Collection</SPAN>&lt;<SPAN style="COLOR: #2b91af">PSObject</SPAN>&gt; results = InvokePowerShell(psscript);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal>This is a very simple function, and in the real world, you will want to make sure that your file read process doesn't error out.&nbsp;&nbsp;The StreamReader is the System.IO namespace, add a Using statement to add it to your code. </P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal>This function will read in the text from the text file and then replace any occurances of "__VMName__" with my value. I add the underscores to my replacement text to make them easy to find.</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal>Here's a sample text file to remove a VM that can be used with the above sample:</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Arial Unicode MS','sans-serif'; FONT-SIZE: 10pt">$MyVMs = @(Get-VM -VMMServer VMMServer1.Contoso.com | where { $_.Name -Match "<SPAN style="BACKGROUND: yellow; mso-highlight: yellow">__VMName__"</SPAN> } )</SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Arial Unicode MS','sans-serif'; FONT-SIZE: 10pt">$MyVMs | Remove-VM<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal>As always, enjoy!</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal>&nbsp;</FONT></o:p></P></SPAN>]]></content:encoded>
    </item>
    <item>
      <title>Working with the SCVMM Templates via Powershell</title>
      <link>https://docs.microsoft.com/archive/blogs/adam/working-with-the-scvmm-templates-via-powershell</link>
      <pubDate>Fri, 26 Mar 2010 08:19:00 GMT</pubDate>
      <dc:creator><![CDATA[Bambam9876]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/adam/2010/03/26/working-with-the-scvmm-templates-via-powershell/</guid>
      <description><![CDATA[Ok... this is my first blog post in quite some time. I've been doing some different coding and since...]]></description>
      <content:encoded><![CDATA[<P>Ok... this is my first blog post in quite some time. I've been doing some different coding and since my ASPNET blog posts helped people out, I thought I'd share what I've learned working with SCVMM.</P>
<P>&nbsp;In this post I'll describe how to request and work with SCVMM template items via powershell and C#.</P>
<P>This post is going to assume you know how to setup C# and work with the System.Management.Automation namespace. If you don't I'll be posting a blog on how I do this next.</P>
<P>In this&nbsp;blog I'm going to show you how to request a specific template and parse the PSObject returned so&nbsp;we can&nbsp;populate a form with the template values.&nbsp;</P>
<P>The first thing I'm going to&nbsp;do&nbsp;is create the powershell script to get a given template. I've created a function that takes in two parameters, the name of the template that I want, and the VMM Server where that template lives:</P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">public</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">&nbsp;<SPAN style="COLOR: #2b91af">void</SPAN> GetTemplate(<SPAN style="COLOR: blue">string</SPAN> TemplateName, <SPAN style="COLOR: blue">string</SPAN> Server)<?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; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">string</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> psscript = <SPAN style="COLOR: #a31515">"Get-Template -VMMServer "</SPAN> + Server + <SPAN style="COLOR: #a31515">" | where {$_.Name -eq '"</SPAN> + TemplateName + <SPAN style="COLOR: #a31515">"'}"</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR></SPAN></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Collection</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;<SPAN style="COLOR: #2b91af">PSObject</SPAN>&gt; results = InvokePowerShell(psscript);<BR></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}</SPAN></P>
<P mce_keep="true">The InvokePowerShell function will be detailed in the next blog post.</P>
<P mce_keep="true">OK this is great, now we have a PSObject that contains all the members of the Template class. But how do we go and get these members so we can use them in C#? With the exception of the custom properties, you just have to know the Member name. Let's take a look:</P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">if</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> (re</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">sults[0].Members[<SPAN style="COLOR: #a31515">"FullName"</SPAN>].Value != <SPAN style="COLOR: blue">null</SPAN>)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">tempTemplate.FullName = results[0].Members[<SPAN style="COLOR: #a31515">"FullName"</SPAN>].Value.ToString();<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}</SPAN></P>
<P mce_keep="true">So here I am assuming that there is only one template that matches the name that we passed into our function. If there are multiple template objects, they will be returned via an array of PSObjects. This is why I just check the first item in the results array. </P>
<P mce_keep="true">From there I just need to know the name of the member of the template class that I'm looking for. There are many ways to do this. You can open the SCVMM powershell window and type Get-Help Get-Template. Or easier, just open the SCVMM powershell window and type get-template. This will return all templates and all members of those templates of the localhost.</P>
<P mce_keep="true">Now I did mention that the custom properties are a bit different to work with. This is because the custom properties are canacatenated together split by a space. We can create an array of custom properties to access our custom properties very easily like this:</P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">string</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">[] customproperties = (<SPAN style="COLOR: blue">string</SPAN>[])results[0].Members[<SPAN style="COLOR: #a31515">"CustomProperties"</SPAN>].Value;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">tempTemplate.CustomProperty1 = customproperties[0];<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><BR><SPAN style="COLOR: blue">string</SPAN> CustomProperty2 = customproperties[1];</SPAN></P>
<P mce_keep="true">The&nbsp;last topic to&nbsp;cover would be setting&nbsp;template settings.&nbsp;I do this&nbsp;by getting the template from SCVMM and then passing the values&nbsp;of the members to be set via the &nbsp;Set-Template cmdlet. This function will set custom property 1 of the template to the value passed into the function.</P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">public</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">&nbsp;<SPAN style="COLOR: blue">void</SPAN> UpdateTemplate(<SPAN style="COLOR: blue">string</SPAN> TemplateName, <SPAN style="COLOR: blue">string</SPAN> myValue)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">{<BR></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&nbsp;&nbsp;&nbsp;&nbsp; string</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> psscript = <SPAN style="COLOR: #a31515">""</SPAN>;<BR><BR></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">&nbsp;&nbsp;&nbsp;&nbsp; psscript += <SPAN style="COLOR: #a31515">"\r\n$Template = Get-Template -VMMServer localhost</SPAN><SPAN style="COLOR: #a31515"> | where {$_.Name -like '"</SPAN> + TemplateName + <SPAN style="COLOR: #a31515">"'}\r\n"</SPAN>;<BR><BR></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">&nbsp;&nbsp;&nbsp;&nbsp; psscript += <SPAN style="COLOR: #a31515">"\r\nSet-Template -Template $Template -Custom1 '"</SPAN> +&nbsp;myValue + <SPAN style="COLOR: #a31515">"'";<BR><BR></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes">&nbsp;&nbsp;&nbsp;&nbsp; Collection</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;<SPAN style="COLOR: #2b91af">PSObject</SPAN>&gt; results = InvokePowerShell(psscript);</SPAN><BR></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}</SPAN><o:p></o:p></P>
<P mce_keep="true">
<P mce_keep="true">If the function succeeds it will return the name of the template in the PSObject results.</P>
<P mce_keep="true">Thats it... pretty straight forward.</P>
<P mce_keep="true">Enjoy!</P>
<P mce_keep="true">&nbsp;</P>
<P mce_keep="true">Adam</P>]]></content:encoded>
    </item>
  </channel>
</rss>