<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.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>Accessing the Hyper-V API: disks.</title><link>http://blogs.technet.com/b/jamesone/archive/2008/04/25/accessing-the-hyper-v-api-disks.aspx</link><description>... In which we create compact, mount, unmount vhds In my last post I said &amp;quot; There are two WMI objects which do most of the work&amp;quot;, and mentioned the one named &amp;quot;Msvm_ImageManagementService&amp;quot;. I spent last week with&amp;#160; poor Internet</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Moving VMs to Hyper-v...</title><link>http://blogs.technet.com/b/jamesone/archive/2008/04/25/accessing-the-hyper-v-api-disks.aspx#3062210</link><pubDate>Wed, 28 May 2008 18:14:40 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3062210</guid><dc:creator>James O'Neill's blog </dc:creator><description>&lt;p&gt;There are 3 things I get asked regularly about Hyper-V. The first is &amp;quot;When can I get it ?&amp;quot;. I've covered&lt;/p&gt;
&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3062210" width="1" height="1"&gt;</description></item><item><title>More on the Hyper-V API</title><link>http://blogs.technet.com/b/jamesone/archive/2008/04/25/accessing-the-hyper-v-api-disks.aspx#3053670</link><pubDate>Sun, 11 May 2008 16:02:25 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3053670</guid><dc:creator>James O'Neill's blog </dc:creator><description>&lt;p&gt;In which we see how to set the number of CPUs I started with getting MSVM Computer System objects - which&lt;/p&gt;
&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3053670" width="1" height="1"&gt;</description></item><item><title>re: Accessing the Hyper-V API: disks.</title><link>http://blogs.technet.com/b/jamesone/archive/2008/04/25/accessing-the-hyper-v-api-disks.aspx#3051145</link><pubDate>Tue, 06 May 2008 20:57:49 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3051145</guid><dc:creator>James ONeill</dc:creator><description>&lt;p&gt;I don't know of anyone who is posting C++. I think the theory is this is *mostly* used in scripts, and if someone wants to build a more complex app they can see what is happening in the script and write their code based on that sample. &lt;/p&gt;
&lt;p&gt;Hopefully someone will correct me with a URL, - if comments have closed on this post please mail it to me. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3051145" width="1" height="1"&gt;</description></item><item><title>re: Accessing the Hyper-V API: disks.</title><link>http://blogs.technet.com/b/jamesone/archive/2008/04/25/accessing-the-hyper-v-api-disks.aspx#3051030</link><pubDate>Tue, 06 May 2008 16:47:10 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3051030</guid><dc:creator>Madhu</dc:creator><description>&lt;p&gt;Can I get C++ code sample for the same thing any where. I find a lot of powershell and vb scripts on net but rarely C++. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3051030" width="1" height="1"&gt;</description></item><item><title>Hyper-v Snapshots part 2.</title><link>http://blogs.technet.com/b/jamesone/archive/2008/04/25/accessing-the-hyper-v-api-disks.aspx#3049217</link><pubDate>Sat, 03 May 2008 14:44:33 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3049217</guid><dc:creator>James O'Neill's blog </dc:creator><description>&lt;p&gt;In my last post I explained how snapshots work and gave a little bit of PowerShell for creating a one&lt;/p&gt;
&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3049217" width="1" height="1"&gt;</description></item><item><title>re: Accessing the Hyper-V API: disks.</title><link>http://blogs.technet.com/b/jamesone/archive/2008/04/25/accessing-the-hyper-v-api-disks.aspx#3048323</link><pubDate>Fri, 02 May 2008 01:28:13 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3048323</guid><dc:creator>parag</dc:creator><description>&lt;p&gt;Thanks a lot James! I was able to get the VHD file path.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;-Parag&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3048323" width="1" height="1"&gt;</description></item><item><title>re: Accessing the Hyper-V API: disks.</title><link>http://blogs.technet.com/b/jamesone/archive/2008/04/25/accessing-the-hyper-v-api-disks.aspx#3047841</link><pubDate>Wed, 30 Apr 2008 23:44:53 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3047841</guid><dc:creator>James ONeill</dc:creator><description>&lt;p&gt;Hi Parag, The answer to that is coming in the next installment &lt;/p&gt;
&lt;p&gt;However, Set $VM to the VM and $controller to 0 or 1 and this will get the path to the controller &lt;/p&gt;
&lt;p&gt;$ctrlPath=((Get-WmiObject -namespace &amp;quot;root\virtualization&amp;quot; -query &amp;quot;Select * from Msvm_ResourceAllocationSettingData where instanceId like '$((Get-VMSettingData $VM).instanceID)%' and resourceSubtype = 'Microsoft Emulated IDE Controller' and address='$Controller'&amp;quot;).path.path).replace(&amp;quot;\&amp;quot;,&amp;quot;\\&amp;quot;) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;Then &amp;nbsp;set $lun to 0 or 1 and this will get the path to the disk &lt;/p&gt;
&lt;p&gt;$drivePath=(Get-WmiObject -namespace &amp;quot;root\virtualization&amp;quot; -query &amp;quot;SELECT * FROM Msvm_ResourceAllocationSettingData WHERE (PARENT='$ctrlPath') and (Address='$LUN')&amp;quot;).path.path.replace(&amp;quot;\&amp;quot;,&amp;quot;\\&amp;quot;) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Then you can get the resource allocation settings data with this &lt;/p&gt;
&lt;p&gt; $rasd=Get-WmiObject -namespace &amp;quot;root\virtualization&amp;quot; -query &amp;quot;Select * from Msvm_ResourceAllocationSettingData where parent = '$DrivePath' &amp;quot; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;The &amp;quot;Connection&amp;quot; field holds the path. If you look at the GUIDs in the VM and the RASD object you can figure how to do the query more simply. But this code was easy to share from the computer I'm on :-) &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3047841" width="1" height="1"&gt;</description></item><item><title>re: Accessing the Hyper-V API: disks.</title><link>http://blogs.technet.com/b/jamesone/archive/2008/04/25/accessing-the-hyper-v-api-disks.aspx#3047789</link><pubDate>Wed, 30 Apr 2008 22:00:33 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3047789</guid><dc:creator>parag_r</dc:creator><description>&lt;p&gt;Hi James,&lt;/p&gt;
&lt;p&gt;Most of these methods take the VHD path as the input. However if I want to perform on of these operations on the virtual disk of a particular VM, how do I get the path for that virtual disk.&lt;/p&gt;
&lt;p&gt;I know we can get it from the GUI and by looking at the xml file for this VM. But I am trying to get this programmatically by using the Hyper-V APIs.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Parag&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3047789" width="1" height="1"&gt;</description></item></channel></rss>