<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Virtual PC Guy's Blog</title><link>http://blogs.msdn.com/b/virtual_pc_guy/</link><description>Talking about Hyper-V and Virtual PC at Microsoft.</description><dc:language>en-US</dc:language><generator>Telligent Community 5.6.583.21163 (Build: 5.6.583.21163)</generator><item><title>Friday afternoon hardware</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2012/02/10/friday-afternoon-hardware.aspx</link><pubDate>Sat, 11 Feb 2012 01:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10266771</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10266771</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2012/02/10/friday-afternoon-hardware.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2012/02/10/friday-afternoon-hardware.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;As is often the case – I have spent most of my Friday afternoon working on my test lab in my office.&amp;#160; This week I have a new toy to play with:&lt;/p&gt;  &lt;p&gt;&lt;img title="WP_001012" style="display: inline; background-image: none;" border="0" alt="WP_001012" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/2308.WP_5F00_001012_5F00_4326700F.jpg" width="644" height="484" /&gt;&lt;/p&gt;  &lt;p&gt;That is a pair of 10G network adapters with the appropriate cable to connect them.&amp;#160; This is actually the first time I have been able to get some 10G networking equipment for myself (most of the good hardware goes straight to the central test lab – and is never seen by us Program Managers).&amp;#160; I have just managed to get it all working – and am looking forward to seeing what it does to my live migration times.&lt;/p&gt;  &lt;p&gt;Speaking of which – and I know I have blogged this before, but it really is useful – if you are planning your network configuration for live migration, this is a great place to start: &lt;a href="http://technet.microsoft.com/en-us/library/ff428137(WS.10).aspx" target="_blank"&gt;Hyper-V: Live Migration Network Configuration Guide&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10266771" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Tech+_2F00_+Microsoft+Talk/">Tech / Microsoft Talk</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>PowerShell Script for Exporting a virtual machine</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2012/02/08/powershell-script-for-exporting-a-virtual-machine.aspx</link><pubDate>Thu, 09 Feb 2012 00:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10265676</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10265676</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2012/02/08/powershell-script-for-exporting-a-virtual-machine.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float: none; margin: 0px; padding: 0px 0px 0px 0px;"&gt;
&lt;script type="text/javascript"&gt;// &lt;![CDATA[
 tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2012/02/08/powershell-script-for-exporting-a-virtual-machine.aspx'; 
// ]]&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;
&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
&lt;p&gt;I need to automate the process of exporting a virtual machine recently &amp;ndash; and when I checked around I found that while there are a number of sample scripts out there that show you how to do this (some even on this blog) they are all written in VBScript.&amp;nbsp; As I am now to the stage where PowerShell is my preferred scripting language &amp;ndash; I sat down and wrote up this short script:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 2000px; background-color: #f4f4f4;"&gt;
&lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: #008000;"&gt;# Function for handling WMI jobs / return values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;Function ProcessResult($result, $successString, $failureString)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;   &lt;span style="color: #008000;"&gt;#Return success if the return value is "0"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;   &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;      {write-host $successString} &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;   &lt;span style="color: #008000;"&gt;#If the return value is not "0" or "4096" then the operation failed&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;   ElseIf ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-ne&lt;/span&gt; 4096)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;      {write-host $failureString &lt;span style="color: #006080;"&gt;" Error value:"&lt;/span&gt; $result.ReturnValue}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;   Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;      {&lt;span style="color: #008000;"&gt;#Get the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;      $job=[WMI]$result.job&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;      &lt;span style="color: #008000;"&gt;#Provide updates if the jobstate is "3" (starting) or "4" (running)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;      &lt;span style="color: #0000ff;"&gt;while&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 3 -or $job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 4)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;         {write-host $job.PercentComplete &lt;span style="color: #006080;"&gt;"% complete"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;          start-sleep 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;          &lt;span style="color: #008000;"&gt;#Refresh the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;          $job=[WMI]$result.job}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;       &lt;span style="color: #008000;"&gt;#A jobstate of "7" means success&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;       &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 7)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;          {write-host $successString&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;          &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; $true}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;       Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;          {write-host $failureString&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorCode:"&lt;/span&gt; $job.ErrorCode&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorDescription"&lt;/span&gt; $job.ErrorDescription&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;          &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; $false}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;       }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the Hyper-V Server to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;$HyperVServer = Read-Host &lt;span style="color: #006080;"&gt;"Specify the Hyper-V Server to use (enter '.' for the local computer)"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the virtual machine to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;$VMName = Read-Host &lt;span style="color: #006080;"&gt;"Specify the name of the virtual machine"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the path to export to&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;$ExportPath = Read-Host &lt;span style="color: #006080;"&gt;"Specify the path to place the exported virtual in"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: #008000;"&gt;# Get the management service&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;$VMMS = gwmi -namespace root\virtualization Msvm_VirtualSystemManagementService -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span style="color: #008000;"&gt;# Get the virtual machine object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;$VM = gwmi MSVM_ComputerSystem -&lt;span style="color: #0000ff;"&gt;filter&lt;/span&gt; &lt;span style="color: #006080;"&gt;"ElementName='$VMName'"&lt;/span&gt; -namespace &lt;span style="color: #006080;"&gt;"root\virtualization"&lt;/span&gt; -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: #008000;"&gt;# Export the virtual machine&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;$result = $VMMS.ExportVirtualSystem($VM, $true, $ExportPath)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"&gt;&lt;span style="color: #008000;"&gt;# Check to make sure we succeeded&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;$exportSucceeded = ProcessResult $result &lt;span style="color: #006080;"&gt;"Virtual machine exported."&lt;/span&gt; &lt;span style="color: #006080;"&gt;"Failed to export virtual machine."&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Some quick notes to make about this script:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;This script takes a Hyper-V server name, a virtual machine name and an export path &amp;ndash; and then performs a full export to the requested location.&lt;/li&gt;
&lt;li&gt;I am using the older (deprecated) ExportVirtualSystem method here &amp;ndash; and not ExportVirtualSystemEx (which I really should do).&amp;nbsp; The main reason for this is that while ExportVirtualSystemEx is a lot more powerful than ExportVirtualSystem, ExportVirtualSystem works perfectly fine for this basic use case and is much easier to script.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cheers, &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10265676" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-26-56-76/simpleExport.zip" length="947" type="application/zip" /><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Developing+on+Windows+Virtual+PC+_2F00_+Virtual+Server+_2F00_+Hyper_2D00_V/">Developing on Windows Virtual PC / Virtual Server / Hyper-V</category></item><item><title>Windows Virtual PC Hotfix for AMD Bulldozer Processors</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2012/01/19/windows-virtual-pc-hotfix-for-amd-bulldozer-processors.aspx</link><pubDate>Thu, 19 Jan 2012 08:05:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10258349</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10258349</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2012/01/19/windows-virtual-pc-hotfix-for-amd-bulldozer-processors.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2012/01/19/windows-virtual-pc-hotfix-for-amd-bulldozer-processors.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;We have just published a hotfix for Windows Virtual PC that addresses a compatibility problem when trying to install on an &lt;a href="http://en.wikipedia.org/wiki/Bulldozer_(microarchitecture)" target="_blank"&gt;AMD Bulldozer&lt;/a&gt; system.&lt;/p&gt;  &lt;p&gt;You can download it here: &lt;a href="http://support.microsoft.com/kb/2519949"&gt;http://support.microsoft.com/kb/2519949&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10258349" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Windows+Virtual+PC/">Windows Virtual PC</category></item><item><title>Hotfix: Guest may crash during live migration</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2012/01/10/hotfix-guest-may-crash-during-live-migration.aspx</link><pubDate>Tue, 10 Jan 2012 23:36:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10255327</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10255327</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2012/01/10/hotfix-guest-may-crash-during-live-migration.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2012/01/10/hotfix-guest-may-crash-during-live-migration.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;We released a new hotfix for Hyper-V today.&lt;/p&gt;  &lt;p&gt;This hotfix addresses an issue where virtual machines may crash (with a STOP 0x000000D1, DRIVER_IRQL_NOT_LESS_OR_EQUAL error) when it is being live migrated.&amp;#160; While this problem is relatively hard to encounter – I would encourage anyone who is using live migration to plan to deploy this hotfix in the near future, as you do not want to hit this accidentally.&lt;/p&gt;  &lt;p&gt;You can download this fix directly from here: &lt;a href="http://support.microsoft.com/kb/2636573"&gt;http://support.microsoft.com/kb/2636573&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Alternatively, it is also being distributed through Windows Update.&amp;#160; Unfortunately it is only available as an optional update though – so you will need to explicitly select to install it on your servers.&amp;#160; &lt;/p&gt;  &lt;p&gt;Either way, this hotfix does require that you reboot the physical server so you will need to plan the deployment of the fix appropriately for your environment.&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10255327" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Converting to a fixed virtual hard disk–for a Server core installation</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/30/converting-to-a-fixed-virtual-hard-disk-for-a-server-core-installation.aspx</link><pubDate>Fri, 30 Dec 2011 22:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10251599</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10251599</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/30/converting-to-a-fixed-virtual-hard-disk-for-a-server-core-installation.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/30/converting-to-a-fixed-virtual-hard-disk-for-a-server-core-installation.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;My last challenge for getting all of my server virtual machines over to fixed-size virtual hard disks is moving some of my Windows Server 2008 R2 virtual machines.&amp;#160; As a reminder, the goal here is to move a virtual machine on a large dynamically expanding virtual hard disk to a smaller fixed-size virtual hard disk. I have used the same technique as I discussed &lt;a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/29/converting-to-a-fixed-virtual-hard-disk-the-hard-way.aspx" target="_blank"&gt;here&lt;/a&gt; – but for obvious reasons the process is quite different, as I cannot use any of the GUI tools.&amp;#160; Here is the process I followed:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Login to the virtual machine using an administrative account&lt;/li&gt;    &lt;li&gt;Run &lt;strong&gt;diskpart&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Check your disks with &lt;strong&gt;list disk&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Select the disk you want to shrink (disk 0 in my case – so &lt;strong&gt;select disk 0&lt;/strong&gt;)&lt;/li&gt;    &lt;li&gt;Check your partitions with &lt;strong&gt;list partition&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Select the partition you want to shrink (partition 4 in my case – so &lt;strong&gt;select partition 3&lt;/strong&gt;)&lt;/li&gt;    &lt;li&gt;Check how much space you can save with &lt;strong&gt;shrink querymax&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Shrink the partition to your desired size (in my case - &lt;strong&gt;shrink desired=70000&lt;/strong&gt; – note that the value here is how much you are shrinking the partition by, not the new size of the partition)&lt;/li&gt;    &lt;li&gt;Check that you are happy with the new size with &lt;strong&gt;list partition&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Exit diskpart with &lt;strong&gt;quit&lt;/strong&gt;      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/1781.image_5F00_7A3C8355.png" target="_blank"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/4428.image_5F00_thumb_5F00_38C1D0FC.png" width="497" height="484" /&gt;&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Once you have shrunk the partition(s) use Windows Server Backup inside the virtual machine (if you have not installed this – you can do so by running &lt;strong&gt;start /w ocsetup WindowsServerBackup &lt;/strong&gt;– don’t worry, this does not take up much space and does not require a reboot to install)&lt;/li&gt;    &lt;li&gt;Run a full backup on a &lt;strong&gt;Remote shared folder&lt;/strong&gt; and provide a file share to use for storing the back&lt;/li&gt;    &lt;ol&gt;     &lt;li&gt;I have a share setup on my parent partition for backing up virtual machines to when I am doing this&lt;/li&gt;      &lt;li&gt;The command that I used for this is: &lt;strong&gt;wbadmin start backup -backupTarget:\\Hyper-V\Backups –allCritical –include:d: –VSSfull         &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/6165.image_5F00_1CB11211.png" target="_blank"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/4034.image_5F00_thumb_5F00_5870AAC4.png" width="459" height="484" /&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;   &lt;/ol&gt;    &lt;li&gt;While the backup is going you can actually jump to the next step.&amp;#160; Creating a new fixed virtual hard disk&lt;/li&gt;    &lt;li&gt;Open the &lt;strong&gt;New Virtual Hard Disk Wizard&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Choose to create a new fixed size virtual hard disk that is the right size for your smaller partitions&lt;/li&gt;    &lt;li&gt;Once the backup is complete, and the fixed virtual hard disk is created, shutdown the virtual machine&lt;/li&gt;    &lt;li&gt;Open the virtual machine settings and replace the dynamic virtual hard disks with the new fixed size virtual hard disks&lt;/li&gt;    &lt;li&gt;Boot the virtual machine using a Windows Server 2008 R2 installation DVD&lt;/li&gt;    &lt;li&gt;After choosing your language, choose &lt;strong&gt;Repair your computer&lt;/strong&gt; (instead of clicking on &lt;strong&gt;Install now&lt;/strong&gt;)&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/li&gt;    &lt;li&gt;Then select &lt;strong&gt;Restore your computer using a system image that you created earlier&lt;/strong&gt; and click &lt;strong&gt;Next&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Click &lt;strong&gt;Cancel&lt;/strong&gt; on the warning that comes up, and then click &lt;strong&gt;Next&lt;/strong&gt; followed by &lt;strong&gt;Advanced…&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Select &lt;strong&gt;Search for a system image on the network&lt;/strong&gt;, followed by clicking &lt;strong&gt;Yes&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;When prompted – enter the network path that you used to create the backup and click &lt;strong&gt;OK&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Select your backup from the table and click &lt;strong&gt;Next&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Select the disks you want to restore and click &lt;strong&gt;Next&lt;/strong&gt;, &lt;strong&gt;Next&lt;/strong&gt;, &lt;strong&gt;Finish&lt;/strong&gt; and &lt;strong&gt;Yes&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;The virtual machine will reboot automatically once the backup is restored&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Once this is all complete, and once you have confirmed that the virtual machine is working properly, you can delete the dynamically expanding disk and the backup.&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10251599" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Converting to a fixed virtual hard disk–the hard way</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/29/converting-to-a-fixed-virtual-hard-disk-the-hard-way.aspx</link><pubDate>Thu, 29 Dec 2011 21:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10251333</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10251333</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/29/converting-to-a-fixed-virtual-hard-disk-the-hard-way.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/29/converting-to-a-fixed-virtual-hard-disk-the-hard-way.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/28/converting-to-a-fixed-virtual-hard-disk-the-easy-way.aspx" target="_blank"&gt;Yesterday&lt;/a&gt; I showed you how to easily convert a dynamically expanding virtual hard disk to a fixed size virtual hard disk.&amp;#160; But, how do you do this if you want to keep your fixed size virtual hard disk as small as possible?&amp;#160; Well, here is the process that I use for my Windows Server 2008 R2 virtual machines:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Login to the virtual machine using an administrative account&lt;/li&gt;    &lt;li&gt;Open &lt;strong&gt;Server Manager&lt;/strong&gt; and select the &lt;strong&gt;Disk Management&lt;/strong&gt; node under the &lt;strong&gt;Storage&lt;/strong&gt; node.&lt;/li&gt;    &lt;li&gt;Right click on the partition that you want to shrink and select &lt;strong&gt;Shrink&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Select how much you want to shrink the partition by&lt;/li&gt;    &lt;ol&gt;     &lt;li&gt;In my case I want to shrink a 250GB partition to 70GB:        &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/3021.image_5F00_54894F68.png" target="_blank"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/0880.image_5F00_thumb_5F00_20E0E30A.png" width="576" height="484" /&gt;&lt;/a&gt;&lt;/li&gt;   &lt;/ol&gt;    &lt;li&gt;Once you have shrunk the partition(s) open &lt;strong&gt;Windows Server Backup&lt;/strong&gt; inside the virtual machine (if you have not installed this – you can do so by choosing to &lt;strong&gt;Add Features&lt;/strong&gt; from &lt;strong&gt;Server Manager&lt;/strong&gt; – don’t worry, this does not take up much space and does not require a reboot to install)&lt;/li&gt;    &lt;li&gt;In &lt;strong&gt;Windows Server Backup&lt;/strong&gt; select &lt;strong&gt;Backup Once…&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;This will open the &lt;strong&gt;Backup Once Wizard&lt;/strong&gt;.&amp;#160; There is only one choice on the first page.&amp;#160; On the second page choose &lt;strong&gt;Full server&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Then select to store the backup on a &lt;strong&gt;Remote shared folder&lt;/strong&gt; and provide a file share to use for storing the back&lt;/li&gt;    &lt;ol&gt;     &lt;li&gt;I have a share setup on my parent partition for backing up virtual machines to when I am doing this&lt;/li&gt;   &lt;/ol&gt;    &lt;li&gt;Complete the wizard and wait for the backup to complete:      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/2746.image3_5F00_79A699D4.png" target="_blank"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/6558.image3_5F00_thumb_5F00_4E6202CD.png" width="579" height="484" /&gt;&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;While the backup is going you can actually jump to the next step.&amp;#160; Creating a new fixed virtual hard disk&lt;/li&gt;    &lt;li&gt;Open the &lt;strong&gt;New Virtual Hard Disk Wizard&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Choose to create a new fixed size virtual hard disk that is the right size for your smaller partitions&lt;/li&gt;    &lt;ol&gt;     &lt;li&gt;Here I am making a 70GB virtual hard disk for my WDS server:        &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/0285.image6_5F00_793A66DF.png" target="_blank"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/6646.image6_5F00_thumb_5F00_070CACDB.png" width="644" height="471" /&gt;&lt;/a&gt;&lt;/li&gt;   &lt;/ol&gt;    &lt;li&gt;Once the backup is complete, and the fixed virtual hard disk is created, shutdown the virtual machine&lt;/li&gt;    &lt;li&gt;Open the virtual machine settings and replace the dynamic virtual hard disks with the new fixed size virtual hard disks&lt;/li&gt;    &lt;li&gt;Boot the virtual machine using a Windows Server 2008 R2 installation DVD&lt;/li&gt;    &lt;li&gt;After choosing your language, choose &lt;strong&gt;Repair your computer&lt;/strong&gt; (instead of clicking on &lt;strong&gt;Install now&lt;/strong&gt;)&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/li&gt;    &lt;li&gt;Then select &lt;strong&gt;Restore your computer using a system image that you created earlier&lt;/strong&gt; and click &lt;strong&gt;Next&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Click &lt;strong&gt;Cancel&lt;/strong&gt; on the warning that comes up, and then click &lt;strong&gt;Next&lt;/strong&gt; followed by &lt;strong&gt;Advanced…&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Select &lt;strong&gt;Search for a system image on the network&lt;/strong&gt;, followed by clicking &lt;strong&gt;Yes&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;When prompted – enter the network path that you used to create the backup and click &lt;strong&gt;OK&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Select your backup from the table and click &lt;strong&gt;Next&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Select the disks you want to restore and click &lt;strong&gt;Next&lt;/strong&gt;, &lt;strong&gt;Next&lt;/strong&gt;, &lt;strong&gt;Finish&lt;/strong&gt; and &lt;strong&gt;Yes&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;The virtual machine will reboot automatically once the backup is restored&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Once this is all complete, and once you have confirmed that the virtual machine is working properly, you can delete the dynamically expanding disk and the backup.&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10251333" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Converting to a fixed virtual hard disk–the easy way</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/28/converting-to-a-fixed-virtual-hard-disk-the-easy-way.aspx</link><pubDate>Thu, 29 Dec 2011 00:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10251331</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10251331</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/28/converting-to-a-fixed-virtual-hard-disk-the-easy-way.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/28/converting-to-a-fixed-virtual-hard-disk-the-easy-way.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;As I discussed &lt;a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/27/time-for-some-server-maintenance.aspx" target="_blank"&gt;yesterday&lt;/a&gt; – I have been working on converting my virtual machines from dynamic virtual hard disks to fixed virtual hard disks.&amp;#160; There are a couple of ways that you can do this.&amp;#160; The easiest way is to just convert the disks using Hyper-V.&amp;#160; To do this you need to:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Shutdown the virtual machine (do not put it into a saved state)&lt;/li&gt;    &lt;li&gt;Open the virtual machine settings and select the virtual hard disks one at a time&lt;/li&gt;    &lt;li&gt;Click the &lt;strong&gt;Edit&lt;/strong&gt; button on the settings page:      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/7701.image_5F00_2134BD5F.png" target="_blank"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/2570.image_5F00_thumb_5F00_20C88A6A.png" width="519" height="484" /&gt;&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;This will open the edit virtual hard disk wizard with the selected virtual hard disk.&amp;#160; Choose the &lt;strong&gt;Convert&lt;/strong&gt; option:      &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/4667.image_5F00_6E64B6EA.png" target="_blank"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/6305.image_5F00_thumb_5F00_1532CD2B.png" width="519" height="484" /&gt;&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Next, enter a file name for the new fixed virtual hard disk:     &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/0042.image_5F00_270F60F8.png" target="_blank"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/4336.image_5F00_thumb_5F00_1FF02480.png" width="518" height="484" /&gt;&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Wait for the virtual hard disk to be converted (this will take a while)&lt;/li&gt;    &lt;li&gt;Change the virtual machine settings to point to the new, fixed, virtual hard disk&lt;/li&gt;    &lt;li&gt;Boot the virtual machine&lt;/li&gt;    &lt;li&gt;Once you have confirmed that everything is working properly, delete the old dynamic virtual hard disks&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;While this process is fairly easy to follow – it has one big drawback.&amp;#160; The fixed virtual hard disk will take up the maximum space of the dynamically expanding virtual hard disk.&amp;#160; For some of my virtual machines I had created small dynamically virtual hard disks, so this worked well.&amp;#160; But for some of them I had created foolishly large dynamically expanding virtual hard disks.&lt;/p&gt;  &lt;p&gt;Tomorrow I will document the process that I used for these virtual machines.&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10251331" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Time for some server maintenance</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/27/time-for-some-server-maintenance.aspx</link><pubDate>Tue, 27 Dec 2011 23:43:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10251324</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10251324</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/27/time-for-some-server-maintenance.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/27/time-for-some-server-maintenance.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;I have had a couple of days off for Christmas, and once the children were happily playing with their new presents, my mind naturally turned to some outstanding server maintenance that I needed to do.&lt;/p&gt;  &lt;p&gt;Top of my list was completing the process of switching all of my servers over to fixed virtual hard disks.&lt;/p&gt;  &lt;p&gt;There are two reasons why you should use fixed virtual hard disks in production environments:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Performance.&lt;/li&gt;    &lt;li&gt;Avoiding oversubscription of disk space.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Given that my servers are only used by me and my family – performance is not a big concern.&amp;#160; And for a long time now I have been using dynamically expanding virtual hard disks for all my server virtual machines.&amp;#160; But recently I had a big problem.&amp;#160; One of my virtual machines started chewing up huge amounts of space.&amp;#160; The result was that my Hyper-V server ran out of space and paused all of my virtual machines (&lt;a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2009/04/22/why-is-my-virtual-machine-paused-critical-hyper-v.aspx" target="_blank"&gt;to stop any of them from crashing&lt;/a&gt;).&amp;#160; When this happened I did some emergency space management, but left most of the virtual machines still using dynamic virtual hard disks.&lt;/p&gt;  &lt;p&gt;Converting a virtual machine from a dynamic virtual hard disk to a fixed virtual hard disk can be quite tricky.&amp;#160; So this week I am going to blog about some of the tips-and-tricks that I have picked up in the process of switching over to fixed virtual hard disks.&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10251324" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Using “built in” applications with Windows XP mode</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/22/using-built-in-applications-with-windows-xp-mode.aspx</link><pubDate>Thu, 22 Dec 2011 22:23:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10250531</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10250531</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/22/using-built-in-applications-with-windows-xp-mode.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/22/using-built-in-applications-with-windows-xp-mode.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Last week I was asked, on Twitter, if it was possible to publish a built in application (like Internet Backgammon) from Windows XP mode.&amp;#160; The answer is: Yes, but it is a little tricky.&lt;/p&gt;  &lt;p&gt;Most people use Windows XP mode to run specific applications that they have that will not run under Windows 7.&amp;#160; These people do not want to have their start menus cluttered with all the applications that populate the Windows XP menu – they just want to access their applications.&amp;#160; For this reason, we block publishing of all of the built in applications in Windows XP – but you can unblock them.&lt;/p&gt;  &lt;p&gt;To test this out – I published Internet Backgammon on one of my systems.&amp;#160; The process that you need to follow is this:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Figure out the path and name of the executable that you want to publish.&amp;#160; In my case this was “bckgzm.exe” in “C:\Program Files\MSN Gaming Zone\Windows”:     &lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/4382.image_5F00_6549C481.png" target="_blank"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/0576.image_5F00_thumb_5F00_10222894.png" width="178" height="244" /&gt;&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Then you need to open RegEdit and go to &lt;strong&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtual Machine\VPCVAppExcludeList&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Search the entries here and you should find a string value with a name of the executable (“bckgzm.exe” in my case) and a data value of the path.&amp;#160; Delete this key.&lt;/li&gt;    &lt;li&gt;Reboot the virtual machine.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;After doing this – the application will appear in the Windows 7 start menu:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/6445.image_5F00_0902EC1C.png" target="_blank"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/3806.image_5F00_thumb_5F00_0FB5F59F.png" width="198" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;And you can run it as an integrated application:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/3480.Capture2_5F00_64715E97.png" target="_blank"&gt;&lt;img title="Capture2" style="display: inline; background-image: none;" border="0" alt="Capture2" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/6136.Capture2_5F00_thumb_5F00_284592EF.png" width="244" height="200" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10250531" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Windows+XP+Mode/">Windows XP Mode</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Windows+Virtual+PC/">Windows Virtual PC</category></item><item><title>Why you should be using BitLocker on your servers</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/21/why-you-should-be-using-bitlocker-on-your-servers.aspx</link><pubDate>Thu, 22 Dec 2011 00:24:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10250172</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>12</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10250172</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/21/why-you-should-be-using-bitlocker-on-your-servers.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/21/why-you-should-be-using-bitlocker-on-your-servers.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;In Windows Vista we introduced “BitLocker” to Windows – a native full disk encryption technology for Windows.&amp;#160; Most people immediately saw the potential for BitLocker on laptops.&amp;#160; Encrypting your laptop meant that if you were ever unfortunate enough to lose your laptop (through theft or forgetfulness) you would not have to worry about someone else getting access to your data.&lt;/p&gt;  &lt;p&gt;But today I would like to explain to you why you want to use BitLocker on your servers too.&amp;#160; All of your servers.&lt;/p&gt;  &lt;p&gt;Recently, I had a hard disk fail in one of my servers.&amp;#160; This happens from time to time, and thanks to RAID it was not a big deal.&amp;#160; I just bought a new drive, popped out the old drive, put in the new one, rebuilt the array and I was off and running.&lt;/p&gt;  &lt;p&gt;But now I have a problem: what do I do with the old drive?&lt;/p&gt;  &lt;p&gt;It’s broken.&amp;#160; So broken that it is hard to delete the data that is on there – but there is data on there none the less.&amp;#160; And despite how unlikely it is that anyone will ever look at it – I am not entirely comfortable with just dropping it in the trash.&amp;#160; Personally, I have had the experience of connecting a broken drive that had been sitting on the shelf for a couple of months and finding that it would work for a couple of hours before failing again.&amp;#160; It is plausible to imagine that someone might find my old drive and hook it up just to see if it worked.&lt;/p&gt;  &lt;p&gt;So how do I get rid of that data?&lt;/p&gt;  &lt;p&gt;Drives these days are quite hard to destroy.&amp;#160; I have tried to pull them apart manually, I have hit them with a hammer, I have even driven a car over one.&amp;#160; They are surprisingly rugged.&amp;#160; You could sit magnets on them – but you won’t know how effective it has been.&amp;#160; Microwaving the drive should be quite good – but would probably damage the microwave as well.&amp;#160; Besides, there is a much simpler solution: use BitLocker.&lt;/p&gt;  &lt;p&gt;Once you have enabled BitLocker on a server – your data is now protected, even if the disk fails.&amp;#160; Especially when the disk fails.&amp;#160; With BitLocker on you can take that failed hard disk and drop it in the bin with no concern of anyone ever getting data off of it.&lt;/p&gt;  &lt;p&gt;Happy times.&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10250172" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Windows+Server+2008+R2/">Windows Server 2008 R2</category></item><item><title>Creating virtual hard disks–the slow way</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/20/creating-virtual-hard-disks-the-slow-way.aspx</link><pubDate>Wed, 21 Dec 2011 00:36:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10249790</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10249790</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/20/creating-virtual-hard-disks-the-slow-way.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/20/creating-virtual-hard-disks-the-slow-way.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Over the weekend I reconfigured one of my main servers.&amp;#160; As part of this process – I had to make some large fixed virtual hard disks (800-1600GB in size).&amp;#160; This took a long time…&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/6087.image_5F00_2020013B.png" target="_blank"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/3348.image_5F00_thumb_5F00_74DB6A33.png" width="480" height="351" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I spent quite some a while looking at this screen…&lt;/p&gt;  &lt;p&gt;In the past I have talked about &lt;a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2008/12/10/why-does-it-take-so-long-to-create-a-fixed-size-virtual-hard-disk.aspx" target="_blank"&gt;why this takes a long time&lt;/a&gt; and I have also talked about a tool that is available that can &lt;a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2009/03/25/quick-fixed-vhd-creation-tool.aspx" target="_blank"&gt;make fixed virtual hard disks quickly&lt;/a&gt;.&amp;#160; So you may be wondering why I would still create virtual hard disks the slow way.&lt;/p&gt;  &lt;p&gt;Well – there are two reasons:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;Support.&lt;/strong&gt;&amp;#160; I know that all of our testing is done using virtual hard disks created by Hyper-V – not by any other tools.&amp;#160; This means that I can have high confidence in the fact that I am unlikely to have problems with these disks – and that if I do have any problems, we will fix them.&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Reliability.&lt;/strong&gt; I like to know that every sector of the disk has been touched before I put it into production.&amp;#160; For the same reason, I always do a full (not quick) format of a disk before putting real workload on it.&amp;#160; I have personally had the experience of having a system where everything appeared to be fine – but creating a 200GB fixed virtual hard disk (the slow way) would cause the system to crash; which in turn revealed that there was a bug in the disk driver I was using.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;In my opinion – when it comes to production systems, sometimes it is just worth taking the time to do things properly.&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10249790" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Testing data protection with virtual machines</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/19/testing-data-protection-with-virtual-machines.aspx</link><pubDate>Mon, 19 Dec 2011 21:54:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10249369</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10249369</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/19/testing-data-protection-with-virtual-machines.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/19/testing-data-protection-with-virtual-machines.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Hopefully what I am about to say is not news to you – but it is worth saying: data protection systems that have not been tested are useless.&amp;#160; Whether you are backing up computers, using RAID or replicating data – the first thing you need to do once you have everything setup is to test that you are actually getting the data protection you think you are getting, and that you can actually recover from a problem.&lt;/p&gt;  &lt;p&gt;Too often, people setup data protection systems and believe everything is fine – until they need to recover lost data.&amp;#160; Then they discover that:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;They have been protecting the wrong data / not protecting the right data&lt;/li&gt;    &lt;li&gt;They do not know how to recover the data, and in the worst case scenario they make a mistake during the recovery process that results in the loss of data that was saved.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;So for this reason – I always test my data protection systems.&amp;#160; To make sure that they are working, and that I actually know how to use them.&lt;/p&gt;  &lt;p&gt;Ordinarily – I use a combination of Windows backup and hardware RAID1 in my home environment.&amp;#160; I know my hardware RAID systems like the back of my hand – and have frequently tested my backups by restoring them into a handy virtual machine (just to confirm that everything is still working).&amp;#160; However, recently I bought some new hard disks that did not approve of my older RAID controller.&amp;#160; After some thought and investigation – I decided that the easiest (and cheapest) solution would be to setup a software mirror using Windows.&lt;/p&gt;  &lt;p&gt;The problem with this is that it has been a long time since I used software mirroring in Windows.&amp;#160; “Dynamic versus basic disks”, “foreign disks”, “pack IDs” are all terms that I could remember – and I could remember that it could be a little tricky.&amp;#160; I needed more confidence than that to trust my data to this.&lt;/p&gt;  &lt;p&gt;Virtual machines to the rescue!&lt;/p&gt;  &lt;p&gt;It took me about an hour to:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Setup a blank virtual machine&lt;/li&gt;    &lt;li&gt;Create a two disk mirror and copy some data onto it&lt;/li&gt;    &lt;li&gt;Simulate losing and replacing a disk, and then rebuilding the mirror&lt;/li&gt;    &lt;li&gt;Simulate rebuilding the system disk and reconnecting the mirror&lt;/li&gt;    &lt;li&gt;Simulate plugging one of the mirror disks into a separate system and recovering data&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/1727.image_5F00_33D474CE.png" target="_blank"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/0245.image_5F00_thumb_5F00_3A877E51.png" width="413" height="348" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;All of this went well – and I was soon setting up my software mirror on hardware, with complete confidence in what I was doing.&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10249369" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Tech+_2F00_+Microsoft+Talk/">Tech / Microsoft Talk</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Linux Integration Services Version v3.2 for Hyper-V now available</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/02/linux-integration-services-version-v3-2-for-hyper-v-now-available.aspx</link><pubDate>Sat, 03 Dec 2011 01:21:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10243886</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10243886</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/02/linux-integration-services-version-v3-2-for-hyper-v-now-available.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/12/02/linux-integration-services-version-v3-2-for-hyper-v-now-available.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Yesterday we released a new version of the Linux Integration Services for Hyper-V.&amp;#160; You can download them directly from here: &lt;a href="http://www.microsoft.com/download/en/details.aspx?id=28188"&gt;http://www.microsoft.com/download/en/details.aspx?id=28188&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Some key changes / new features to call out are:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Integrated mouse support       &lt;br /&gt;&lt;/strong&gt;Yay!&amp;#160; This means that you no longer need to install a separate package to get integrated mouse support, and will not have to worry about the mouse being captured by the virtual machine.&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Updated network drivers that work with the Windows 8 Developer Preview builds&lt;/strong&gt;      &lt;br /&gt;I am happy to see this – as I am running this build of Windows *everywhere* at the moment&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Fixes the issue with SCVMM compatibility&lt;/strong&gt;      &lt;br /&gt;The problem is documented here: &lt;a href="http://support.microsoft.com/kb/2586286"&gt;http://support.microsoft.com/kb/2586286&lt;/a&gt; – and should not be a problem anymore.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;For more details, check out the link and read the documentation.&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10243886" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Operating+Systems+under+Virtual+PC+_2F00_+Virtual+Server+_2F00_+Hyper_2D00_V/">Operating Systems under Virtual PC / Virtual Server / Hyper-V</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Hyper-V Extensible Switch in Windows Server 8</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/11/10/hyper-v-extensible-switch-in-windows-server-8.aspx</link><pubDate>Thu, 10 Nov 2011 09:40:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10235700</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10235700</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/11/10/hyper-v-extensible-switch-in-windows-server-8.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/11/10/hyper-v-extensible-switch-in-windows-server-8.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Mike Neil has blogged about the Hyper-V Extensible Switch in Windows Server 8 over on the Server and Cloud Platform blog (here: &lt;a title="http://blogs.technet.com/b/server-cloud/archive/2011/11/08/windows-server-8-introducing-hyper-v-extensible-switch.aspx" href="http://blogs.technet.com/b/server-cloud/archive/2011/11/08/windows-server-8-introducing-hyper-v-extensible-switch.aspx"&gt;http://blogs.technet.com/b/server-cloud/archive/2011/11/08/windows-server-8-introducing-hyper-v-extensible-switch.aspx&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;This is something that I am actually quite excited about.&amp;#160; Specifically – I am really interested to see what ideas other people are able to come up with around extending the capabilities of virtual networking.&lt;/p&gt;  &lt;p&gt;As Mike mentions – we talked about this at //BUILD/ and you can watch the recording of the session here: &lt;a title="SAC-559T" href="http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-559T"&gt;SAC-559T&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The highlight of this session for me was the number of partners that we already have looking for ways to build in new functionality here.&amp;#160; Some of the partner solutions that were presented in this session include:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Support for the Cisco Nexus 1000V for Hyper-V, in addition to the Cisco VM-FEX extension with direct I/O (SR-IOV). &lt;/li&gt;    &lt;li&gt;Inmon with their traffic capturing &amp;amp;analysis and their sFlow product. &lt;/li&gt;    &lt;li&gt;5Nine showed their Virtual Firewall. &lt;/li&gt;    &lt;li&gt;Broadcom demonstrated a DoS Prevention extension. &lt;/li&gt;    &lt;li&gt;NEC demonstrated an extension that converts Hyper-V to an OpenFlow virtual switch and integrates it with their Programmable Flow product.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;And this is just the beginning of what people are going to build here.&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10235700" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Windows+Server+8/">Windows Server 8</category></item><item><title>Friday Afternoon–hardware time</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/11/04/friday-afternoon-hardware-time.aspx</link><pubDate>Fri, 04 Nov 2011 23:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10232358</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10232358</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/11/04/friday-afternoon-hardware-time.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/11/04/friday-afternoon-hardware-time.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;I spend far too much time in meetings these days.&amp;#160; But I try to keep my Friday afternoons free of meetings – and often use this time to update my various servers and try out new configurations.&amp;#160; Today it is time to rebuild some of my storage:&lt;/p&gt;  &lt;p&gt;&lt;img title="RAID" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="RAID" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/7762.RAID_5F00_3CB431BE.jpg" width="489" height="368" /&gt;&lt;/p&gt;  &lt;p&gt;Specifically I am throwing a bunch of disks into one of my servers and setting up a storage space to play around with (you can learn more about spaces here: &lt;a title="http://channel9.msdn.com/events/BUILD/BUILD2011/SAC-474T" href="http://channel9.msdn.com/events/BUILD/BUILD2011/SAC-474T"&gt;http://channel9.msdn.com/events/BUILD/BUILD2011/SAC-474T&lt;/a&gt;). &lt;/p&gt;  &lt;p&gt;These days I find that the most common cause of performance issues in my virtualized environments is the storage subsystem.&amp;#160; So I try to build systems with as much parallelism in the storage as possible – as I will be running dozens of virtual machines at the same time and a single disk just will not cut it for performance.&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10232358" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Tech+_2F00_+Microsoft+Talk/">Tech / Microsoft Talk</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Personal/">Personal</category></item><item><title>Using CPU Reserve to enforce virtual processor ratio</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/11/03/using-cpu-reserve-to-enforce-virtual-processor-ratio.aspx</link><pubDate>Thu, 03 Nov 2011 18:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10232353</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10232353</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/11/03/using-cpu-reserve-to-enforce-virtual-processor-ratio.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float: none; margin: 0px; padding: 0px 0px 0px 0px;"&gt;
&lt;script type="text/javascript"&gt;// &lt;![CDATA[
 tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/11/03/using-cpu-reserve-to-enforce-virtual-processor-ratio.aspx'; 
// ]]&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;
&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
&lt;p&gt;On Monday I posted a script for configuring virtual machine CPU scheduler settings.&amp;nbsp; This script got me to thinking about another use for the virtual machine CPU reserve.&lt;/p&gt;
&lt;p&gt;You see, it can also be used to ensure that you do not unintentionally start too many virtual machines at once.&lt;/p&gt;
&lt;p&gt;If you were to set the CPU reserve on each virtual machine at 20% (or at 20,000 using the underlying API) then it is not possible to start extra virtual machines once you hit a ratio of 5 virtual processors for each physical processor.&amp;nbsp; This is actually what System Center Virtual Machine Manager does to enforce limits on the system.&lt;/p&gt;
&lt;p&gt;Here is a script that will do just that:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; overflow: auto; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 2000px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;"&gt;
&lt;div id="codeSnippet" style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Function for handling WMI jobs / return values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;Function ProcessResult($result, $successString, $failureString)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;#Return success if the return value is "0"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      {write-host $successString} &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;#If the return value is not "0" or "4096" then the operation failed&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   ElseIf ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-ne&lt;/span&gt; 4096)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      {write-host $failureString &lt;span style="color: #006080;"&gt;" Error value:"&lt;/span&gt; $result.ReturnValue}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;      {&lt;span style="color: #008000;"&gt;#Get the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      $job=[WMI]$result.job&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      &lt;span style="color: #008000;"&gt;#Provide updates if the jobstate is "3" (starting) or "4" (running)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;      &lt;span style="color: #0000ff;"&gt;while&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 3 -or $job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 4)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;         {write-host $job.PercentComplete &lt;span style="color: #006080;"&gt;"% complete"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          start-sleep 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #008000;"&gt;#Refresh the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          $job=[WMI]$result.job}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;       &lt;span style="color: #008000;"&gt;#A jobstate of "7" means success&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 7)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          {write-host $successString}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          {write-host $failureString&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorCode:"&lt;/span&gt; $job.ErrorCode&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorDescription"&lt;/span&gt; $job.ErrorDescription}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the Hyper-V Server to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$HyperVServer = Read-Host &lt;span style="color: #006080;"&gt;"Specify the Hyper-V Server to use (enter '.' for the local computer)"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the new CPU reservation&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$NewReservation = Read-Host &lt;span style="color: #006080;"&gt;"Specify the CPU reservation (from 0-100000)"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the management service&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$VMMS = gwmi -namespace root\virtualization Msvm_VirtualSystemManagementService -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get all VSSDs for non-snapshots&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$VSSDs = gwmi &lt;span style="color: #006080;"&gt;"MSVM_VirtualSystemSettingData"&lt;/span&gt; -namespace &lt;span style="color: #006080;"&gt;"root\virtualization"&lt;/span&gt; -computername $HyperVServer | ? {$_.SettingType &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 3}  &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #0000ff;"&gt;foreach&lt;/span&gt; ($VSSD &lt;span style="color: #0000ff;"&gt;in&lt;/span&gt; $VSSDs)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;# Get the related VM&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   $VM = $VSSD.getRelated(&lt;span style="color: #006080;"&gt;"MSVM_ComputerSystem"&lt;/span&gt;) | select -first 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;# Get the processor setting data&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   $ProcSetting = $VSSD.getRelated(&lt;span style="color: #006080;"&gt;"Msvm_ProcessorSettingData"&lt;/span&gt;) | select -first 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;# Update ProcSetting with the new value&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   $ProcSetting.Reservation = $NewReservation&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;# Apply the changes to the processor setting data back to the virtual machine&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   $result = $VMMS.ModifyVirtualSystemResources($VM, $ProcSetting.GetText(1))&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;# Process the result&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   $successMessage = &lt;span style="color: #006080;"&gt;"Updated processor scheduling settings on '"&lt;/span&gt; + $VM.ElementName + &lt;span style="color: #006080;"&gt;"'"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   $failureMessage = &lt;span style="color: #006080;"&gt;"Failed to update processor scheduling settings on "&lt;/span&gt; + $VM.ElementName + &lt;span style="color: #006080;"&gt;"'"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   ProcessResult $result $successMessage $failureMessage&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you run this script and specify &amp;ldquo;20000&amp;rdquo; then you will be able to run at a ratio of 5 virtual processors for each physical processor.&amp;nbsp; If you run this script and specify &amp;ldquo;25000&amp;rdquo; then you will be able to run at a ratio of 4 virtual processors for each physical processor.&lt;/p&gt;
&lt;p&gt;Note that this will not apply to any virtual machine snapshots, or to any newly created virtual machines, so it is a little fragile as a solution.&lt;/p&gt;
&lt;p&gt;Cheers, &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10232353" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-23-23-53/SetProcReservationOnAll.zip" length="1358" type="application/zip" /><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Developing+on+Windows+Virtual+PC+_2F00_+Virtual+Server+_2F00_+Hyper_2D00_V/">Developing on Windows Virtual PC / Virtual Server / Hyper-V</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Diagnosing a cause of PXE boot failure</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/11/02/diagnosing-a-cause-of-pxe-boot-failure.aspx</link><pubDate>Wed, 02 Nov 2011 18:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10232349</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10232349</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/11/02/diagnosing-a-cause-of-pxe-boot-failure.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/11/02/diagnosing-a-cause-of-pxe-boot-failure.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;The other day I was trying to boot a virtual machine over the network using my Windows Deployment Services (WDS) Server.&amp;#160; This normally works fine – but for some reason I was getting nothing but errors.&amp;#160; Sometimes I would get a DHCP failure, other times I received varied PXE error messages:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/0804.PXEFail_5F00_3720F729.png" target="_blank"&gt;&lt;img title="PXEFail" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="PXEFail" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/4606.PXEFail_5F00_thumb_5F00_6FCBA136.png" width="420" height="326" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;After some investigation I stumbled on to the problem.&amp;#160; There was a MAC address conflict.&amp;#160; While Hyper-V will not let MAC address conflicts happen on a single server – but you can still have conflicts happen between multiple Hyper-V servers.&amp;#160; John Howard has talked about this extensively here: &lt;a title="http://blogs.technet.com/b/jhoward/archive/2008/07/15/hyper-v-mac-address-allocation-and-apparent-network-issues-mac-collisions-can-cause.aspx" href="http://blogs.technet.com/b/jhoward/archive/2008/07/15/hyper-v-mac-address-allocation-and-apparent-network-issues-mac-collisions-can-cause.aspx"&gt;http://blogs.technet.com/b/jhoward/archive/2008/07/15/hyper-v-mac-address-allocation-and-apparent-network-issues-mac-collisions-can-cause.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Once I realized what was happening – I quickly changed the virtual machine to use a static MAC address and set the MAC address to a unique value:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/0410.image_5F00_01A83504.png" target="_blank"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/8836.image_5F00_thumb_5F00_6F5F6E41.png" width="429" height="404" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Then network installation worked fine.&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10232349" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Operating+Systems+under+Virtual+PC+_2F00_+Virtual+Server+_2F00_+Hyper_2D00_V/">Operating Systems under Virtual PC / Virtual Server / Hyper-V</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Setting VM CPU scheduler settings with PowerShell [Hyper-V]</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/31/setting-vm-cpu-scheduler-settings-with-powershell-hyper-v.aspx</link><pubDate>Tue, 01 Nov 2011 02:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10231919</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10231919</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/31/setting-vm-cpu-scheduler-settings-with-powershell-hyper-v.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float: none; margin: 0px; padding: 0px 0px 0px 0px;"&gt;
&lt;script type="text/javascript"&gt;// &lt;![CDATA[
 tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/31/setting-vm-cpu-scheduler-settings-with-powershell-hyper-v.aspx'; 
// ]]&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;
&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
&lt;p&gt;A while ago I did a number of posts talking about the different controls that are available to you in regards to how Hyper-V schedules virtual machine processor resources (&lt;a title="Hyper-V CPU Scheduling&amp;ndash;Part 1" href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/02/14/hyper-v-cpu-scheduling-part-1.aspx"&gt;Hyper-V CPU Scheduling&amp;ndash;Part 1&lt;/a&gt;, &lt;a title="Hyper-V CPU Scheduling&amp;ndash;Part 2" href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/02/15/hyper-v-cpu-scheduling-part-2.aspx"&gt;Hyper-V CPU Scheduling&amp;ndash;Part 2&lt;/a&gt;, &lt;a title="Hyper-V CPU Scheduling&amp;ndash;Part 3" href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/02/17/hyper-v-cpu-scheduling-part-3.aspx"&gt;Hyper-V CPU Scheduling&amp;ndash;Part 3&lt;/a&gt; and &lt;a title="Hyper-V CPU Scheduling&amp;ndash;Part 4" href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/02/18/hyper-v-cpu-scheduling-part-4.aspx"&gt;Hyper-V CPU Scheduling&amp;ndash;Part 4&lt;/a&gt;).&amp;nbsp; Today I want to share a PowerShell script that shows you how to configure these settings programmatically:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; overflow: auto; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 2000px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;"&gt;
&lt;div id="codeSnippet" style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Function for handling WMI jobs / return values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;Function ProcessResult($result, $successString, $failureString)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;#Return success if the return value is "0"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      {write-host $successString} &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;#If the return value is not "0" or "4096" then the operation failed&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   ElseIf ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-ne&lt;/span&gt; 4096)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      {write-host $failureString &lt;span style="color: #006080;"&gt;" Error value:"&lt;/span&gt; $result.ReturnValue}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;      {&lt;span style="color: #008000;"&gt;#Get the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      $job=[WMI]$result.job&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      &lt;span style="color: #008000;"&gt;#Provide updates if the jobstate is "3" (starting) or "4" (running)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;      &lt;span style="color: #0000ff;"&gt;while&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 3 -or $job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 4)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;         {write-host $job.PercentComplete &lt;span style="color: #006080;"&gt;"% complete"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          start-sleep 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #008000;"&gt;#Refresh the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          $job=[WMI]$result.job}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;       &lt;span style="color: #008000;"&gt;#A jobstate of "7" means success&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 7)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          {write-host $successString}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          {write-host $failureString&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorCode:"&lt;/span&gt; $job.ErrorCode&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorDescription"&lt;/span&gt; $job.ErrorDescription}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the Hyper-V Server to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$HyperVServer = Read-Host &lt;span style="color: #006080;"&gt;"Specify the Hyper-V Server to use (enter '.' for the local computer)"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the virtual machine to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$VMName = Read-Host &lt;span style="color: #006080;"&gt;"Specify the name of the virtual machine"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the management service&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$VMMS = gwmi -namespace root\virtualization Msvm_VirtualSystemManagementService -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the virtual machine object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$VM = gwmi MSVM_ComputerSystem -&lt;span style="color: #0000ff;"&gt;filter&lt;/span&gt; &lt;span style="color: #006080;"&gt;"ElementName='$VMName'"&lt;/span&gt; -namespace &lt;span style="color: #006080;"&gt;"root\virtualization"&lt;/span&gt; -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# SettingType = 3 ensures that we do not get snapshots&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$SystemSettingData = $VM.getRelated(&lt;span style="color: #006080;"&gt;"Msvm_VirtualSystemSettingData"&lt;/span&gt;) | where {$_.SettingType &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 3}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the processor setting data&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$ProcSetting = $SystemSettingData.getRelated(&lt;span style="color: #006080;"&gt;"Msvm_ProcessorSettingData"&lt;/span&gt;) | select -first 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get new values from the user&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$NewReservation = Read-Host &lt;span style="color: #006080;"&gt;"Specify the CPU reserve (from 0-10000) [Currently:"&lt;/span&gt;$ProcSetting.Reservation&lt;span style="color: #006080;"&gt;"]"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$NewLimit = Read-Host &lt;span style="color: #006080;"&gt;"Specify the CPU limit (from 0-10000) [Currently:"&lt;/span&gt;$ProcSetting.Limit&lt;span style="color: #006080;"&gt;"]"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$NewWeight = Read-Host &lt;span style="color: #006080;"&gt;"Specify the CPU weight (from 0-10000) [Currently:"&lt;/span&gt;$ProcSetting.weight&lt;span style="color: #006080;"&gt;"]"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Update ProcSetting with the new values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$ProcSetting.Reservation = $NewReservation&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$ProcSetting.Limit = $NewLimit&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$ProcSetting.weight = $NewWeight&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Apply the changes to the processor setting data back to the virtual machine&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$result = $VMMS.ModifyVirtualSystemResources($VM, $ProcSetting.GetText(1))&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Process the result&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;ProcessResult $result &lt;span style="color: #006080;"&gt;"Updated processor scheduling settings."&lt;/span&gt; &lt;span style="color: #006080;"&gt;"Failed to update processor scheduling settings."&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Cheers, &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10231919" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-23-19-19/ProcSchedulerSettings.zip" length="1422" type="application/zip" /><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Developing+on+Windows+Virtual+PC+_2F00_+Virtual+Server+_2F00_+Hyper_2D00_V/">Developing on Windows Virtual PC / Virtual Server / Hyper-V</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>How many virtual processors does a virtual machine have?</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/25/how-many-virtual-processors-does-a-virtual-machine-have.aspx</link><pubDate>Tue, 25 Oct 2011 15:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10229148</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10229148</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/25/how-many-virtual-processors-does-a-virtual-machine-have.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float: none; margin: 0px; padding: 0px 0px 0px 0px;"&gt;
&lt;script type="text/javascript"&gt;// &lt;![CDATA[
 tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/25/how-many-virtual-processors-does-a-virtual-machine-have.aspx';
// ]]&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;
&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
&lt;p&gt;A recent forum poster asked:&lt;/p&gt;
&lt;p&gt;How do I write a script that figures out how many virtual processors a virtual machine has, when it is offline (i.e. not running)?&lt;/p&gt;
&lt;p&gt;His question showed that he had made a classic mistake when working with the Hyper-V WMI APIs.&amp;nbsp; You see Hyper-V usually has two WMI objects for many parts of the virtual machine &amp;ndash; one of them representing the settings and one of them representing the live object itself.&lt;/p&gt;
&lt;p&gt;Case in hand: for a virtual processor you have &amp;ldquo;MSVM_Processor&amp;rdquo; which represents the live object, and you have &amp;ldquo;MSVM_ProcessorSettingData&amp;rdquo; which represents its settings.&lt;/p&gt;
&lt;p&gt;Looking at the wrong object at the wrong time can cause problems.&amp;nbsp; Live objects should be used for gathering usage information about running virtual machines &amp;ndash; settings object should be used for getting and setting configuration details.&amp;nbsp; 90% of the time &amp;ndash; the settings object is what you want (and 90% of the time it is the object that ends with the string &amp;ldquo;SettingData&amp;rdquo;).&lt;/p&gt;
&lt;p&gt;Here is a simple script that gets a virtual machines processor count using both objects:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; overflow: auto; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 2000px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;"&gt;
&lt;div id="codeSnippet" style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the Hyper-V Server to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$HyperVServer = Read-Host &lt;span style="color: #006080;"&gt;"Specify the Hyper-V Server to use (enter '.' for the local computer)"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the virtual machine to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$VMName = Read-Host &lt;span style="color: #006080;"&gt;"Specify the name of the virtual machine"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the management service&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$VMMS = gwmi -namespace root\virtualization Msvm_VirtualSystemManagementService -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the virtual machine object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$VM = gwmi MSVM_ComputerSystem -&lt;span style="color: #0000ff;"&gt;filter&lt;/span&gt; &lt;span style="color: #006080;"&gt;"ElementName='$VMName'"&lt;/span&gt; -namespace &lt;span style="color: #006080;"&gt;"root\virtualization"&lt;/span&gt; -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Set the stage&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;Write-host &lt;span style="color: #006080;"&gt;"There are two ways to get a virtual machines processor count, the wrong way and the right way..."&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;write-host&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Let's do the wrong way first&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the virtual processor objects&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$vProcs = $vm.GetRelated(&lt;span style="color: #006080;"&gt;"MSVM_Processor"&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;write-host&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;Write-host &lt;span style="color: #006080;"&gt;"Doing it the wrong way (using Msvm_Processor):"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;write-host&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;write-host &lt;span style="color: #006080;"&gt;"The"&lt;/span&gt; $VMName &lt;span style="color: #006080;"&gt;"virtual machine is configured with"&lt;/span&gt; $vProcs.count &lt;span style="color: #006080;"&gt;"virtual processors."&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Now let's do it the right way&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# SettingType = 3 ensures that we do not get snapshots&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$SystemSettingData = $VM.getRelated(&lt;span style="color: #006080;"&gt;"Msvm_VirtualSystemSettingData"&lt;/span&gt;) | where {$_.SettingType &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 3}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the processor setting data&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$ProcSetting = $SystemSettingData.getRelated(&lt;span style="color: #006080;"&gt;"Msvm_ProcessorSettingData"&lt;/span&gt;) | select -first 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;write-host&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;Write-host &lt;span style="color: #006080;"&gt;"Doing it the right way (using Msvm_ProcessorSettingData):"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;write-host&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;write-host &lt;span style="color: #006080;"&gt;"The"&lt;/span&gt; $VMName &lt;span style="color: #006080;"&gt;"virtual machine is configured with"&lt;/span&gt; $ProcSetting.VirtualQuantity &lt;span style="color: #006080;"&gt;"virtual processors."&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If I run this on a running virtual machine &amp;ndash; both methods return the same thing:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/8176.image_5F00_1F40D5A7.png"&gt;&lt;img title="image" style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/7080.image_5F00_thumb_5F00_05D8D26D.png" width="445" height="289" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But if the virtual machine is not running &amp;ndash; only the MVSM_ProcessorSettingData actually tells me what I want to know:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/2625.image_5F00_05006C83.png"&gt;&lt;img title="image" style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/5023.image_5F00_thumb_5F00_0BB37606.png" width="448" height="291" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Cheers, &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10229148" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-22-91-48/VMProcCount.zip" length="895" type="application/zip" /><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Developing+on+Windows+Virtual+PC+_2F00_+Virtual+Server+_2F00_+Hyper_2D00_V/">Developing on Windows Virtual PC / Virtual Server / Hyper-V</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Running DOS fullscreen applications in Windows XP Mode</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/24/running-dos-fullscreen-applications-in-windows-xp-mode.aspx</link><pubDate>Mon, 24 Oct 2011 18:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10228984</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10228984</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/24/running-dos-fullscreen-applications-in-windows-xp-mode.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;script type="text/javascript"&gt; tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/24/running-dos-fullscreen-applications-in-windows-xp-mode.aspx'; &lt;/script&gt; &lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Here is a problem that I was asked about a while ago:&lt;/p&gt;  &lt;p&gt;When I try to start a DOS application that switches to fullscreen in Windows XP Mode – it fails with an error that states “The video device failed to initialize for fullscreen mode.&amp;#160; Choose ‘Close’ to terminate the application.”&amp;#160; Why is this happening – and how do I fix it?&lt;/p&gt;  &lt;p&gt;The reason why this happens is because Windows XP mode uses Remote Desktop technology for its integrated mode – and Remote Desktop does not support the video modes needed by fullscreen DOS applications.&amp;#160; The simplest way to make this work is to &lt;a href="http://blogs.msdn.com/b/virtual_pc_guy/archive/2009/06/19/disabling-integrated-mode-in-windows-virtual-pc.aspx" target="_blank"&gt;disable integrated mode&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;This will get you from failure:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/5775.fullscreendos_5F00_4CC1085C.png" target="_blank"&gt;&lt;img title="fullscreendos" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="fullscreendos" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/2146.fullscreendos_5F00_thumb_5F00_537411DF.png" width="244" height="178" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To success:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/3225.fullscreendos2_5F00_7A42281F.png" target="_blank"&gt;&lt;img title="fullscreendos2" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="fullscreendos2" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-41-22-metablogapi/0676.fullscreendos2_5F00_thumb_5F00_0C1EBBED.png" width="244" height="173" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10228984" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Windows+XP+Mode/">Windows XP Mode</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Windows+Virtual+PC/">Windows Virtual PC</category></item><item><title>Deleting a snapshot sub-tree–via PowerShell [Hyper-V]</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/21/deleting-a-snapshot-subtree-via-powershell-hyper-v.aspx</link><pubDate>Fri, 21 Oct 2011 17:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10225594</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10225594</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/21/deleting-a-snapshot-subtree-via-powershell-hyper-v.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float: none; margin: 0px; padding: 0px 0px 0px 0px;"&gt;
&lt;script type="text/javascript"&gt;// &lt;![CDATA[
 tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/21/deleting-a-snapshot-subtree-via-powershell-hyper-v.aspx'; 
// ]]&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;
&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
&lt;p&gt;Here is a dangerous script!&amp;nbsp; Given a virtual machine name and a snapshot name, it will delete the specified snapshot *and* any snapshots underneath it in the snapshot tree that Hyper-V manager displays:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; overflow: auto; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 2000px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;"&gt;
&lt;div id="codeSnippet" style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Function for handling WMI jobs / return values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;Function ProcessResult($result, $successString, $failureString)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;#Return success if the return value is "0"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      {write-host $successString} &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;#If the return value is not "0" or "4096" then the operation failed&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   ElseIf ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-ne&lt;/span&gt; 4096)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      {write-host $failureString &lt;span style="color: #006080;"&gt;" Error value:"&lt;/span&gt; $result.ReturnValue}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;      {&lt;span style="color: #008000;"&gt;#Get the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      $job=[WMI]$result.job&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      &lt;span style="color: #008000;"&gt;#Provide updates if the jobstate is "3" (starting) or "4" (running)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;      &lt;span style="color: #0000ff;"&gt;while&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 3 -or $job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 4)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;         {write-host $job.PercentComplete &lt;span style="color: #006080;"&gt;"% complete"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          start-sleep 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #008000;"&gt;#Refresh the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          $job=[WMI]$result.job}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;       &lt;span style="color: #008000;"&gt;#A jobstate of "7" means success&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 7)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          {write-host $successString&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; $true}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;       Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          {write-host $failureString&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorCode:"&lt;/span&gt; $job.ErrorCode&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorDescription"&lt;/span&gt; $job.ErrorDescription&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; $false}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the Hyper-V Server to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$HyperVServer = Read-Host &lt;span style="color: #006080;"&gt;"Specify the Hyper-V Server to use (enter '.' for the local computer)"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the virtual machine to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$VMName = Read-Host &lt;span style="color: #006080;"&gt;"Specify the name of the virtual machine"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the name of the snapshot to delete the tree from&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$SnapshotName = Read-Host &lt;span style="color: #006080;"&gt;"Specify the name of the snapshot to delete the tree from (warning - a lot of snapshots will be deleted)"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the management service&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$VMMS = gwmi -namespace root\virtualization Msvm_VirtualSystemManagementService -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the virtual machine object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$VM = gwmi MSVM_ComputerSystem -&lt;span style="color: #0000ff;"&gt;filter&lt;/span&gt; &lt;span style="color: #006080;"&gt;"ElementName='$VMName'"&lt;/span&gt; -namespace &lt;span style="color: #006080;"&gt;"root\virtualization"&lt;/span&gt; -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Find the snapshot that we want to delete&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$Snapshot = gwmi -Namespace root\virtualization -Query &lt;span style="color: #006080;"&gt;"Associators Of {$VM} Where AssocClass=Msvm_ElementSettingData ResultClass=Msvm_VirtualSystemSettingData"&lt;/span&gt; | where {$_.ElementName &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; $SnapshotName} | select -first 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Delete the snapshot&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$result = $VMMS.RemoveVirtualSystemSnapshotTree($Snapshot)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Check to make sure we succeeded&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$deleteSucceeded = ProcessResult $result &lt;span style="color: #006080;"&gt;"Deleted snapshot tree."&lt;/span&gt; &lt;span style="color: #006080;"&gt;"Failed to delete snapshot tree."&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Note that this script actually uses a different WMI method to delete the snapshot sub-tree (when compared to deleting a single snapshot).&amp;nbsp; There is no way to stop the deletion once it is started, and there is no confirmation prompt in this script &amp;ndash; so be careful when you use it!&lt;/p&gt;
&lt;p&gt;Cheers, &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10225594" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-22-55-94/DeleteSnapshotTree.zip" length="1305" type="application/zip" /><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Developing+on+Windows+Virtual+PC+_2F00_+Virtual+Server+_2F00_+Hyper_2D00_V/">Developing on Windows Virtual PC / Virtual Server / Hyper-V</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Deleting a snapshot–via PowerShell [Hyper-V]</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/20/deleting-a-snapshot-via-powershell-hyper-v.aspx</link><pubDate>Thu, 20 Oct 2011 17:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10225592</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10225592</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/20/deleting-a-snapshot-via-powershell-hyper-v.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float: none; margin: 0px; padding: 0px 0px 0px 0px;"&gt;
&lt;script type="text/javascript"&gt;// &lt;![CDATA[
 tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/20/deleting-a-snapshot-via-powershell-hyper-v.aspx'; 
// ]]&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;
&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
&lt;p&gt;Here is a script that will allow you to delete a single snapshot from a Hyper-V virtual machine:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; overflow: auto; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 2000px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;"&gt;
&lt;div id="codeSnippet" style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Function for handling WMI jobs / return values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;Function ProcessResult($result, $successString, $failureString)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;#Return success if the return value is "0"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      {write-host $successString} &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;#If the return value is not "0" or "4096" then the operation failed&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   ElseIf ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-ne&lt;/span&gt; 4096)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      {write-host $failureString &lt;span style="color: #006080;"&gt;" Error value:"&lt;/span&gt; $result.ReturnValue}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;      {&lt;span style="color: #008000;"&gt;#Get the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      $job=[WMI]$result.job&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      &lt;span style="color: #008000;"&gt;#Provide updates if the jobstate is "3" (starting) or "4" (running)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;      &lt;span style="color: #0000ff;"&gt;while&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 3 -or $job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 4)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;         {write-host $job.PercentComplete &lt;span style="color: #006080;"&gt;"% complete"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          start-sleep 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #008000;"&gt;#Refresh the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          $job=[WMI]$result.job}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;       &lt;span style="color: #008000;"&gt;#A jobstate of "7" means success&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 7)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          {write-host $successString&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; $true}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;       Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          {write-host $failureString&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorCode:"&lt;/span&gt; $job.ErrorCode&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorDescription"&lt;/span&gt; $job.ErrorDescription&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; $false}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the Hyper-V Server to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$HyperVServer = Read-Host &lt;span style="color: #006080;"&gt;"Specify the Hyper-V Server to use (enter '.' for the local computer)"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the virtual machine to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$VMName = Read-Host &lt;span style="color: #006080;"&gt;"Specify the name of the virtual machine"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the name of the snapshot to delete&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$SnapshotName = Read-Host &lt;span style="color: #006080;"&gt;"Specify the name of the snapshot to delete"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the management service&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$VMMS = gwmi -namespace root\virtualization Msvm_VirtualSystemManagementService -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the virtual machine object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$VM = gwmi MSVM_ComputerSystem -&lt;span style="color: #0000ff;"&gt;filter&lt;/span&gt; &lt;span style="color: #006080;"&gt;"ElementName='$VMName'"&lt;/span&gt; -namespace &lt;span style="color: #006080;"&gt;"root\virtualization"&lt;/span&gt; -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Find the snapshot that we want to delete&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$Snapshot = gwmi -Namespace root\virtualization -Query &lt;span style="color: #006080;"&gt;"Associators Of {$VM} Where AssocClass=Msvm_ElementSettingData ResultClass=Msvm_VirtualSystemSettingData"&lt;/span&gt; | where {$_.ElementName &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; $SnapshotName} | select -first 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Delete the snapshot&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$result = $VMMS.RemoveVirtualSystemSnapshot($Snapshot)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Check to make sure we succeeded&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$deleteSucceeded = ProcessResult $result &lt;span style="color: #006080;"&gt;"Deleted snapshot."&lt;/span&gt; &lt;span style="color: #006080;"&gt;"Failed to delete snapshot."&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Cheers, &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10225592" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-22-55-92/DeleteSnapshot.zip" length="1248" type="application/zip" /><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Developing+on+Windows+Virtual+PC+_2F00_+Virtual+Server+_2F00_+Hyper_2D00_V/">Developing on Windows Virtual PC / Virtual Server / Hyper-V</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Applying a snapshot–via PowerShell [Hyper-V]</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/19/applying-a-snapshot-via-powershell-hyper-v.aspx</link><pubDate>Wed, 19 Oct 2011 17:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10225588</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10225588</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/19/applying-a-snapshot-via-powershell-hyper-v.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float: none; margin: 0px; padding: 0px 0px 0px 0px;"&gt;
&lt;script type="text/javascript"&gt;// &lt;![CDATA[
 tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/19/applying-a-snapshot-via-powershell-hyper-v.aspx'; 
// ]]&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;
&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
&lt;p&gt;Now that we know how to take a snapshot, and how to list snapshots &amp;ndash; let&amp;rsquo;s start applying snapshots:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; overflow: auto; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 2000px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;"&gt;
&lt;div id="codeSnippet" style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Function for handling WMI jobs / return values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;Function ProcessResult($result, $successString, $failureString)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;#Return success if the return value is "0"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      {write-host $successString} &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;#If the return value is not "0" or "4096" then the operation failed&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   ElseIf ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-ne&lt;/span&gt; 4096)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      {write-host $failureString &lt;span style="color: #006080;"&gt;" Error value:"&lt;/span&gt; $result.ReturnValue}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;      {&lt;span style="color: #008000;"&gt;#Get the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      $job=[WMI]$result.job&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      &lt;span style="color: #008000;"&gt;#Provide updates if the jobstate is "3" (starting) or "4" (running)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;      &lt;span style="color: #0000ff;"&gt;while&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 3 -or $job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 4)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;         {write-host $job.PercentComplete &lt;span style="color: #006080;"&gt;"% complete"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          start-sleep 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #008000;"&gt;#Refresh the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          $job=[WMI]$result.job}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;       &lt;span style="color: #008000;"&gt;#A jobstate of "7" means success&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 7)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          {write-host $successString&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; $true}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;       Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          {write-host $failureString&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorCode:"&lt;/span&gt; $job.ErrorCode&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorDescription"&lt;/span&gt; $job.ErrorDescription&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; $false}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the Hyper-V Server to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$HyperVServer = Read-Host &lt;span style="color: #006080;"&gt;"Specify the Hyper-V Server to use (enter '.' for the local computer)"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the virtual machine to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$VMName = Read-Host &lt;span style="color: #006080;"&gt;"Specify the name of the virtual machine"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the name of the snapshot to apply&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$SnapshotName = Read-Host &lt;span style="color: #006080;"&gt;"Specify the name of the snapshot to apply"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the management service&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$VMMS = gwmi -namespace root\virtualization Msvm_VirtualSystemManagementService -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the virtual machine object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$VM = gwmi MSVM_ComputerSystem -&lt;span style="color: #0000ff;"&gt;filter&lt;/span&gt; &lt;span style="color: #006080;"&gt;"ElementName='$VMName'"&lt;/span&gt; -namespace &lt;span style="color: #006080;"&gt;"root\virtualization"&lt;/span&gt; -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Find the snapshot that we want to apply&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$Snapshot = gwmi -Namespace root\virtualization -Query &lt;span style="color: #006080;"&gt;"Associators Of {$VM} Where AssocClass=Msvm_ElementSettingData ResultClass=Msvm_VirtualSystemSettingData"&lt;/span&gt; | where {$_.ElementName &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; $SnapshotName} | select -first 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Apply the snapshot&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$result = $VMMS.ApplyVirtualSystemSnapshot($VM, $Snapshot)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Check to make sure we succeeded&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$applySucceeded = ProcessResult $result &lt;span style="color: #006080;"&gt;"Snapshot applied."&lt;/span&gt; &lt;span style="color: #006080;"&gt;"Failed to apply snapshot."&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This is a fairly standard Hyper-V WMI script.&amp;nbsp; One thing to be aware of is that this operation will fail if the virtual machine is running when you try to apply the snapshot &amp;ndash; the virtual machine needs to be turned off or put into a saved state first.&lt;/p&gt;
&lt;p&gt;Cheers, &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10225588" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-22-55-88/ApplySnapshot.zip" length="1247" type="application/zip" /><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Developing+on+Windows+Virtual+PC+_2F00_+Virtual+Server+_2F00_+Hyper_2D00_V/">Developing on Windows Virtual PC / Virtual Server / Hyper-V</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Listing snapshots–via PowerShell [Hyper-V]</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/18/listing-snapshots-via-powershell-hyper-v.aspx</link><pubDate>Tue, 18 Oct 2011 16:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10225584</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10225584</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/18/listing-snapshots-via-powershell-hyper-v.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float: none; margin: 0px; padding: 0px 0px 0px 0px;"&gt;
&lt;script type="text/javascript"&gt;// &lt;![CDATA[
 tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/18/listing-snapshots-via-powershell-hyper-v.aspx'; 
// ]]&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;
&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
&lt;p&gt;After the relatively trick &amp;ldquo;taking a snapshot&amp;rdquo; script &amp;ndash; today&amp;rsquo;s snapshot script is quite easy.&amp;nbsp; Listing the snapshots that a virtual machine has:&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; overflow: auto; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 2000px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;"&gt;
&lt;div id="codeSnippet" style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the Hyper-V Server to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$HyperVServer = Read-Host &lt;span style="color: #006080;"&gt;"Specify the Hyper-V Server to use (enter '.' for the local computer)"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the virtual machine to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$VMName = Read-Host &lt;span style="color: #006080;"&gt;"Specify the name of the virtual machine"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the management service&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$VMMS = gwmi -namespace root\virtualization Msvm_VirtualSystemManagementService -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the virtual machine object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$VM = gwmi MSVM_ComputerSystem -&lt;span style="color: #0000ff;"&gt;filter&lt;/span&gt; &lt;span style="color: #006080;"&gt;"ElementName='$VMName'"&lt;/span&gt; -namespace &lt;span style="color: #006080;"&gt;"root\virtualization"&lt;/span&gt; -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get snapshot objects associated with the virtual machine&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$Snapshots = gwmi -Namespace root\virtualization -Query &lt;span style="color: #006080;"&gt;"Associators Of {$VM} Where AssocClass=Msvm_ElementSettingData ResultClass=Msvm_VirtualSystemSettingData"&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;write-host&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;write-host $VMName &lt;span style="color: #006080;"&gt;"has the following snapshots:"&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Display a formatted list of snapshots&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$Snapshots | sort CreationTime | Format-Table -Property @{n=&lt;span style="color: #006080;"&gt;'Snapshot Name'&lt;/span&gt;;e={$_.ElementName}}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;One thing to point out here is that I am using a WMI query that looks at the association class (MSVM_ElementSettingData) as well as the result class (MSVM_VirtualSystemSettingData).&amp;nbsp; The reason why I do this is that if you grab all MSVM_VirtualSystemSettingData classes that are associated with a virtual machine &amp;ndash; you will get two extra entries: one for the active virtual machine, and one for the latest snapshot (which results in one of your snapshots being duplicated).&amp;nbsp; The method that I am using here ensures that you only get snapshots, and you do not get any duplicates.&lt;/p&gt;
&lt;p&gt;Cheers, &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10225584" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-22-55-84/ListSnapshots.zip" length="744" type="application/zip" /><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Developing+on+Windows+Virtual+PC+_2F00_+Virtual+Server+_2F00_+Hyper_2D00_V/">Developing on Windows Virtual PC / Virtual Server / Hyper-V</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item><item><title>Taking a snapshot–via PowerShell [Hyper-V]</title><link>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/17/taking-a-snapshot-via-powershell-hyper-v.aspx</link><pubDate>Mon, 17 Oct 2011 16:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10225580</guid><dc:creator>Ben Armstrong [MSFT]</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/virtual_pc_guy/rsscomments.aspx?WeblogPostID=10225580</wfw:commentRss><comments>http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/17/taking-a-snapshot-via-powershell-hyper-v.aspx#comments</comments><description>&lt;div class="wlWriterHeaderFooter" style="float: none; margin: 0px; padding: 0px 0px 0px 0px;"&gt;
&lt;script type="text/javascript"&gt;// &lt;![CDATA[
 tweetmeme_url = 'http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/17/taking-a-snapshot-via-powershell-hyper-v.aspx'; 
// ]]&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;
&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
&lt;p&gt;This week I am going to be sharing a bunch of scripts that show you how to interact with virtual machine snapshots in Hyper-V.&amp;nbsp; And I am going to start off with the hardest one &amp;ndash; taking a snapshot:&lt;/p&gt;
&lt;div class="csharpcode"&gt;
&lt;div id="codeSnippetWrapper" style="cursor: text; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 97.5%; overflow: auto; direction: ltr; text-align: left; margin: 20px 0px 10px; line-height: 12pt; max-height: 2000px; background-color: #f4f4f4; border: silver 1px solid; padding: 4px;"&gt;
&lt;div id="codeSnippet" style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Function for handling WMI jobs / return values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;Function ProcessResult($result, $successString, $failureString)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;#Return success if the return value is "0"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      {write-host $successString} &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   &lt;span style="color: #008000;"&gt;#If the return value is not "0" or "4096" then the operation failed&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;   ElseIf ($result.ReturnValue &lt;span style="color: #cc6633;"&gt;-ne&lt;/span&gt; 4096)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      {write-host $failureString &lt;span style="color: #006080;"&gt;" Error value:"&lt;/span&gt; $result.ReturnValue}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;   Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;      {&lt;span style="color: #008000;"&gt;#Get the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      $job=[WMI]$result.job&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;      &lt;span style="color: #008000;"&gt;#Provide updates if the jobstate is "3" (starting) or "4" (running)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;      &lt;span style="color: #0000ff;"&gt;while&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 3 -or $job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 4)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;         {write-host $job.PercentComplete &lt;span style="color: #006080;"&gt;"% complete"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          start-sleep 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #008000;"&gt;#Refresh the job object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          $job=[WMI]$result.job}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;       &lt;span style="color: #008000;"&gt;#A jobstate of "7" means success&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       &lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($job.JobState &lt;span style="color: #cc6633;"&gt;-eq&lt;/span&gt; 7)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          {write-host $successString&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; $true}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;       Else&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          {write-host $failureString&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorCode:"&lt;/span&gt; $job.ErrorCode&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;          write-host &lt;span style="color: #006080;"&gt;"ErrorDescription"&lt;/span&gt; $job.ErrorDescription&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;          &lt;span style="color: #0000ff;"&gt;return&lt;/span&gt; $false}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;       }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the Hyper-V Server to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$HyperVServer = Read-Host &lt;span style="color: #006080;"&gt;"Specify the Hyper-V Server to use (enter '.' for the local computer)"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the virtual machine to use&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$VMName = Read-Host &lt;span style="color: #006080;"&gt;"Specify the name of the virtual machine"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Prompt for the name of the new snapshot&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$SnapshotName = Read-Host &lt;span style="color: #006080;"&gt;"Specify the name of the new snapshot"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the management service&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$VMMS = gwmi -namespace root\virtualization Msvm_VirtualSystemManagementService -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Get the virtual machine object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$VM = gwmi MSVM_ComputerSystem -&lt;span style="color: #0000ff;"&gt;filter&lt;/span&gt; &lt;span style="color: #006080;"&gt;"ElementName='$VMName'"&lt;/span&gt; -namespace &lt;span style="color: #006080;"&gt;"root\virtualization"&lt;/span&gt; -computername $HyperVServer&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Take the snapshot&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;$result = $VMMS.CreateVirtualSystemSnapshot($VM)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# Process the results&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;$snapshotSucceeded = ProcessResult $result &lt;span style="color: #006080;"&gt;"The snapshot was taken."&lt;/span&gt; &lt;span style="color: #006080;"&gt;"Failed to take snapshot."&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;# If the snapshot is created - rename it&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;&lt;span style="color: #0000ff;"&gt;if&lt;/span&gt; ($snapshotSucceeded)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;    &lt;span style="color: #008000;"&gt;# Get the job object from the results&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;    $job2=[WMI]$result.job&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;    &lt;span style="color: #008000;"&gt;# Get the snapshot that is assocated with the completed job&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;    $newSnapshot = $job2.GetRelated(&lt;span style="color: #006080;"&gt;"Msvm_VirtualSystemSettingData"&lt;/span&gt;) | select -first 1&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;    &lt;span style="color: #008000;"&gt;# Change the "ElementName" &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;    $newSnapshot.ElementName = $SnapshotName&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;    &lt;span style="color: #008000;"&gt;# Apply the changes to the snapshot&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;    $result2 = $VMMS.ModifyVirtualSystem($VM, $newSnapshot.GetText(1))&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;    &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;    &lt;span style="color: #008000;"&gt;# Check to see if renaming the snapshot succeeds&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: white; border-style: none; padding: 0px;"&gt;    $renameSucceeded = ProcessResult $result2 &lt;span style="color: #006080;"&gt;"The new snapshot was renamed."&lt;/span&gt; &lt;span style="color: #006080;"&gt;"Failed to rename the new snapshot."&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; color: black; overflow: visible; direction: ltr; text-align: left; margin: 0em; line-height: 12pt; background-color: #f4f4f4; border-style: none; padding: 0px;"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The tricky part of this script is not actually taking the snapshot (which is done with &lt;strong&gt;CreateVirtualSystemSnapshot&lt;/strong&gt;) but naming the snapshot after it is taken (Hyper-V always auto-generates a snapshot name for you &amp;ndash; and you need to rename it if you want to have a custom snapshot name).&amp;nbsp; Actually, that isn&amp;rsquo;t hard either &amp;ndash; the hard bit is *finding* the snapshot after it is taken in order to name it.&lt;/p&gt;
&lt;p&gt;The secret here is that the new snapshot object (in WMI) will actually be associated with the job object once the snapshot is complete.&amp;nbsp; So this script waits for the snapshot job to complete, then it gets the related system setting data from the completed job, and uses that to rename the snapshot.&amp;nbsp; Once you have figured this bit out &amp;ndash; the rest is quite straight forward.&lt;/p&gt;
&lt;p&gt;Cheers, &lt;br /&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10225580" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-22-55-80/TakeSnapshot.zip" length="1380" type="application/zip" /><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Developing+on+Windows+Virtual+PC+_2F00_+Virtual+Server+_2F00_+Hyper_2D00_V/">Developing on Windows Virtual PC / Virtual Server / Hyper-V</category><category domain="http://blogs.msdn.com/b/virtual_pc_guy/archive/tags/Hyper_2D00_V/">Hyper-V</category></item></channel></rss>
