{"id":19576,"date":"2016-07-05T10:32:47","date_gmt":"2016-07-05T09:32:47","guid":{"rendered":"https:\/\/aidanfinn.com\/?p=19576"},"modified":"2016-07-05T10:50:44","modified_gmt":"2016-07-05T09:50:44","slug":"optimize-hyper-v-vm-placement-to-match-csv-ownership","status":"publish","type":"post","link":"https:\/\/aidanfinn.com\/?p=19576","title":{"rendered":"Optimize Hyper-V VM Placement To Match CSV Ownership"},"content":{"rendered":"<p>This post shares a PowerShell script to automatically live migrate clustered Hyper-V virtual machines to the host that owns the CSV that the VM is stored on. The example below should work nicely with a 2-node cluster, such as a <a href=\"https:\/\/aidanfinn.com\/?p=19444\" target=\"_blank\">cluster-in-a-box<\/a>.<\/p>\n<p>For lots of reasons, you get the best performance for VMs on a Hyper-V cluster if:<\/p>\n<ul>\n<li>Host X owns CSV Y AND<\/li>\n<li>The VMs that are stored on CSV Y are running on Host X.<\/li>\n<\/ul>\n<p>This continues into WS2016, as we\u2019ve seen by analysing the performance <a href=\"https:\/\/aidanfinn.com\/?p=18840\" target=\"_blank\">enhancements of ReFS for VHDX operations<\/a>. <em>In summary, the ODX-like enhancements work best when the CSV and VM placement are identical as above.<\/em><\/p>\n<p>I wrote a script, with little bits taken from several places (scripting is the art of copy &amp; paste), to analyse a cluster and then move virtual machines to the best location. The method of the script is:<\/p>\n<ol>\n<li>Move CSV ownership to what you have architected.<\/li>\n<li>Locate the VMs that need to move.<\/li>\n<li>Order that list of VMs based on RAM. I want to move the smallest VMs first in case there is memory contention.<\/li>\n<li>Live migrate VMs based on that ordered list.<\/li>\n<\/ol>\n<p>What\u2019s missing? Error handling \ud83d\ude42<\/p>\n<p>What do you need to do?<\/p>\n<ul>\n<li>You need to add variables for your CSVs and hosts.<\/li>\n<li>Modify\/add lines to move CSV ownership to the required hosts.<\/li>\n<li>Balance the deployment of your VMs across your CSVs.<\/li>\n<\/ul>\n<p>Here\u2019s the script. I doubt the code is optimal, but it works. Note that the Live Migration command (Move-ClusterVirtualMachineRole) has been commented out so you can see what the script will do without it actually doing anything to your VM placement. Feel free to use, modify, etc.<\/p>\n<pre class=\"lang:default decode:true\">#List your CSVs \r\n$CSV1 = \"CSV1\" \r\n$CSV2 = \"CSV2\"\r\n\r\n#List your hosts \r\n$CSV1Node = \"Host01\" \r\n$CSV2Node = \"Host02\"\r\n\r\nfunction ListVMs () \r\n{ \r\n\u00a0\u00a0\u00a0 Write-Host \"`n`n`n`n`n`nAnalysing the cluster $Cluster ...\"\r\n\r\n\u00a0\u00a0\u00a0 $Cluster = Get-Cluster \r\n\u00a0\u00a0\u00a0 $AllCSV = Get-ClusterSharedVolume -Cluster $Cluster | Sort-Object Name\r\n\r\n\u00a0\u00a0\u00a0 $VMMigrationList = @()\r\n\r\n\u00a0\u00a0\u00a0 ForEach ($CSV in $AllCSV) \r\n\u00a0\u00a0\u00a0 { \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $CSVVolumeInfo = $CSV | Select -Expand SharedVolumeInfo \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $CSVPath = ($CSVVolumeInfo).FriendlyVolumeName\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $FixedCSVPath = $CSVPath -replace '\\\\', '\\\\'\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #Get the VMs where VM placement doesn't match CSV ownership\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $VMsToMove = Get-ClusterGroup | ? {($_.GroupType \u2013eq 'VirtualMachine') -and ( $_.OwnerNode -ne $CSV.OWnernode.Name)} | Get-VM | Where-object {($_.path -match $FixedCSVPath)} \r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #Build up a list of VMs including their memory size \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ForEach ($VM in $VMsToMove) \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 { \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $VMRAM = (Get-VM -ComputerName $VM.ComputerName -Name $VM.Name).MemoryAssigned\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $VMMigrationList += ,@($VM.Name, $CSV.OWnernode.Name, $VMRAM) \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0 #Order the VMs based on memory size, ascending \r\n\u00a0\u00a0\u00a0 $VMMigrationList = $VMMigrationList | sort-object @{Expression={$_[2]}; Ascending=$true}\r\n\r\n\u00a0\u00a0\u00a0 Return $VMMigrationList \r\n}\r\n\r\nfunction MoveVM ($TheVMs) \r\n{\r\n\r\n\u00a0\u00a0\u00a0 foreach ($VM in $TheVMs) \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 { \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $VMName = $VM[0] \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $VMDestination = $VM[1] \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Write-Host \"`nMove $VMName to $VMDestination\" \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #Move-ClusterVirtualMachineRole -Name $VMName -Node $VMDestination -MigrationType Live \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\r\n}\r\n\r\ncls\r\n\r\n#Configure which node will own wich CSV \r\nMove-ClusterSharedVolume -Name $CSV1 -Node $CSV1Node | Out-Null \r\nMove-ClusterSharedVolume -Name $CSV2 -Node $CSV2Node | Out-Null\r\n\r\n$SortedVMs = @{}\r\n\r\n#Get a sorted list of VMs, ordered by assign memory \r\n$SortedVMs = ListVMs\r\n\r\n#Live Migrate the VMs, so that their host is also their CSV owner \r\nMoveVM $SortedVMs<\/pre>\n<p>Possible improvements:<\/p>\n<ul>\n<li>My ListVMs algorithm probably can be improved.<\/li>\n<li>The Live Migration piece also can be improved. It only does 1 VM at a time, but you could implement parallelism using jobs.<\/li>\n<li>Quick Migration should be used for non-running VMs. I haven&#8217;t handles that situation.<\/li>\n<li>You could opt to use Quick Migration for low priority VMs &#8211; if that&#8217;s your policy.<\/li>\n<li>The script could be modified to start using parameters, e.g. Analyse (not move), QuickMigrateLow, QuickMigrate (instead of Live Migrate), etc.<\/li>\n<\/ul>\n<div id=\"scid:0767317B-992E-4b12-91E0-4F059A8CECA8:7f45c8bc-fc73-4927-ab2c-5c87a670aaa9\" class=\"wlWriterEditableSmartContent\" style=\"float: none; margin: 0px; display: inline; padding: 0px;\">Technorati Tags: <a href=\"http:\/\/technorati.com\/tags\/Hyper-V\" rel=\"tag\">Hyper-V<\/a>,<a href=\"http:\/\/technorati.com\/tags\/PowerShell\" rel=\"tag\">PowerShell<\/a>,<a href=\"http:\/\/technorati.com\/tags\/Scripting\" rel=\"tag\">Scripting<\/a>,<a href=\"http:\/\/technorati.com\/tags\/Failover+Clustering\" rel=\"tag\">Failover Clustering<\/a>,<a href=\"http:\/\/technorati.com\/tags\/Storage\" rel=\"tag\">Storage<\/a>,<a href=\"http:\/\/technorati.com\/tags\/Storage+Spaces\" rel=\"tag\">Storage Spaces<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This post shares a PowerShell script to automatically live migrate clustered Hyper-V virtual machines to the host that owns the CSV that the VM is stored on. The example below should work nicely with a 2-node cluster, such as a cluster-in-a-box. For lots of reasons, you get the best performance for VMs on a Hyper-V &hellip; <a href=\"https:\/\/aidanfinn.com\/?p=19576\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Optimize Hyper-V VM Placement To Match CSV Ownership&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":18900,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_wpcom_ai_launchpad_first_post":false,"footnotes":""},"categories":[20],"tags":[63,181,87,189,99,100],"class_list":["post-19576","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hyper-v","tag-failover-clustering","tag-hyper-v","tag-powershell","tag-scripting","tag-storage","tag-storage-spaces"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.5 - aioseo.com -->\n\t<meta name=\"description\" content=\"This post shares a PowerShell script to automatically live migrate clustered Hyper-V virtual machines to the host that owns the CSV that the VM is stored on. The example below should work nicely with a 2-node cluster, such as a cluster-in-a-box. For lots of reasons, you get the best performance for VMs on a Hyper-V\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"AFinn\"\/>\n\t<meta name=\"google-site-verification\" content=\"TDKjbi2McB2eLIfL6KwPB3aQqv5E-mbcb2QYIcovGaI\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/aidanfinn.com\/?p=19576\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.5\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_GB\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Aidan Finn, IT Pro - A blog covering Azure, Hyper-V, Windows Server, desktop, systems management, deployment, and so on ...\" \/>\n\t\t<meta property=\"og:type\" content=\"activity\" \/>\n\t\t<meta property=\"og:title\" content=\"Optimize Hyper-V VM Placement To Match CSV Ownership | Aidan Finn, IT Pro\" \/>\n\t\t<meta property=\"og:description\" content=\"This post shares a PowerShell script to automatically live migrate clustered Hyper-V virtual machines to the host that owns the CSV that the VM is stored on. The example below should work nicely with a 2-node cluster, such as a cluster-in-a-box. For lots of reasons, you get the best performance for VMs on a Hyper-V\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/aidanfinn.com\/?p=19576\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@joe_elway\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Optimize Hyper-V VM Placement To Match CSV Ownership | Aidan Finn, IT Pro\" \/>\n\t\t<meta name=\"twitter:description\" content=\"This post shares a PowerShell script to automatically live migrate clustered Hyper-V virtual machines to the host that owns the CSV that the VM is stored on. The example below should work nicely with a 2-node cluster, such as a cluster-in-a-box. For lots of reasons, you get the best performance for VMs on a Hyper-V\" \/>\n\t\t<meta name=\"twitter:creator\" content=\"@joe_elway\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?p=19576#article\",\"name\":\"Optimize Hyper-V VM Placement To Match CSV Ownership | Aidan Finn, IT Pro\",\"headline\":\"Optimize Hyper-V VM Placement To Match CSV Ownership\",\"author\":{\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?author=1#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/aidanfinn.com\\\/wp-content\\\/uploads\\\/2015\\\/09\\\/5315.powershell_2D00_logo.gif_2D00_550x01.png\",\"width\":550,\"height\":372},\"datePublished\":\"2016-07-05T10:32:47+01:00\",\"dateModified\":\"2016-07-05T10:50:44+01:00\",\"inLanguage\":\"en-GB\",\"commentCount\":6,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?p=19576#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?p=19576#webpage\"},\"articleSection\":\"Hyper-V, Failover Clustering, Hyper-V, PowerShell, Scripting, Storage, Storage Spaces\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?p=19576#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/aidanfinn.com\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?cat=20#listItem\",\"name\":\"Hyper-V\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?cat=20#listItem\",\"position\":2,\"name\":\"Hyper-V\",\"item\":\"https:\\\/\\\/aidanfinn.com\\\/?cat=20\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?p=19576#listItem\",\"name\":\"Optimize Hyper-V VM Placement To Match CSV Ownership\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?p=19576#listItem\",\"position\":3,\"name\":\"Optimize Hyper-V VM Placement To Match CSV Ownership\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?cat=20#listItem\",\"name\":\"Hyper-V\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/#person\",\"name\":\"AFinn\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?p=19576#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/65fde4aa9f2ab1cf1514ae320a37ec682d9398ce5791d3c2dd1e8670a71ceea0?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"AFinn\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?author=1#author\",\"url\":\"https:\\\/\\\/aidanfinn.com\\\/?author=1\",\"name\":\"AFinn\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?p=19576#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/65fde4aa9f2ab1cf1514ae320a37ec682d9398ce5791d3c2dd1e8670a71ceea0?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"AFinn\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?p=19576#webpage\",\"url\":\"https:\\\/\\\/aidanfinn.com\\\/?p=19576\",\"name\":\"Optimize Hyper-V VM Placement To Match CSV Ownership | Aidan Finn, IT Pro\",\"description\":\"This post shares a PowerShell script to automatically live migrate clustered Hyper-V virtual machines to the host that owns the CSV that the VM is stored on. The example below should work nicely with a 2-node cluster, such as a cluster-in-a-box. For lots of reasons, you get the best performance for VMs on a Hyper-V\",\"inLanguage\":\"en-GB\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?p=19576#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?author=1#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?author=1#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/aidanfinn.com\\\/wp-content\\\/uploads\\\/2015\\\/09\\\/5315.powershell_2D00_logo.gif_2D00_550x01.png\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?p=19576\\\/#mainImage\",\"width\":550,\"height\":372},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/?p=19576#mainImage\"},\"datePublished\":\"2016-07-05T10:32:47+01:00\",\"dateModified\":\"2016-07-05T10:50:44+01:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/#website\",\"url\":\"https:\\\/\\\/aidanfinn.com\\\/\",\"name\":\"Aidan Finn, IT Pro\",\"description\":\"A blog covering Azure, Hyper-V, Windows Server, desktop, systems management, deployment, and so on ...\",\"inLanguage\":\"en-GB\",\"publisher\":{\"@id\":\"https:\\\/\\\/aidanfinn.com\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Optimize Hyper-V VM Placement To Match CSV Ownership | Aidan Finn, IT Pro","description":"This post shares a PowerShell script to automatically live migrate clustered Hyper-V virtual machines to the host that owns the CSV that the VM is stored on. The example below should work nicely with a 2-node cluster, such as a cluster-in-a-box. For lots of reasons, you get the best performance for VMs on a Hyper-V","canonical_url":"https:\/\/aidanfinn.com\/?p=19576","robots":"max-image-preview:large","keywords":"","webmasterTools":{"google-site-verification":"TDKjbi2McB2eLIfL6KwPB3aQqv5E-mbcb2QYIcovGaI","miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/aidanfinn.com\/?p=19576#article","name":"Optimize Hyper-V VM Placement To Match CSV Ownership | Aidan Finn, IT Pro","headline":"Optimize Hyper-V VM Placement To Match CSV Ownership","author":{"@id":"https:\/\/aidanfinn.com\/?author=1#author"},"publisher":{"@id":"https:\/\/aidanfinn.com\/#person"},"image":{"@type":"ImageObject","url":"https:\/\/aidanfinn.com\/wp-content\/uploads\/2015\/09\/5315.powershell_2D00_logo.gif_2D00_550x01.png","width":550,"height":372},"datePublished":"2016-07-05T10:32:47+01:00","dateModified":"2016-07-05T10:50:44+01:00","inLanguage":"en-GB","commentCount":6,"mainEntityOfPage":{"@id":"https:\/\/aidanfinn.com\/?p=19576#webpage"},"isPartOf":{"@id":"https:\/\/aidanfinn.com\/?p=19576#webpage"},"articleSection":"Hyper-V, Failover Clustering, Hyper-V, PowerShell, Scripting, Storage, Storage Spaces"},{"@type":"BreadcrumbList","@id":"https:\/\/aidanfinn.com\/?p=19576#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/aidanfinn.com\/#listItem","position":1,"name":"Home","item":"https:\/\/aidanfinn.com\/","nextItem":{"@type":"ListItem","@id":"https:\/\/aidanfinn.com\/?cat=20#listItem","name":"Hyper-V"}},{"@type":"ListItem","@id":"https:\/\/aidanfinn.com\/?cat=20#listItem","position":2,"name":"Hyper-V","item":"https:\/\/aidanfinn.com\/?cat=20","nextItem":{"@type":"ListItem","@id":"https:\/\/aidanfinn.com\/?p=19576#listItem","name":"Optimize Hyper-V VM Placement To Match CSV Ownership"},"previousItem":{"@type":"ListItem","@id":"https:\/\/aidanfinn.com\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/aidanfinn.com\/?p=19576#listItem","position":3,"name":"Optimize Hyper-V VM Placement To Match CSV Ownership","previousItem":{"@type":"ListItem","@id":"https:\/\/aidanfinn.com\/?cat=20#listItem","name":"Hyper-V"}}]},{"@type":"Person","@id":"https:\/\/aidanfinn.com\/#person","name":"AFinn","image":{"@type":"ImageObject","@id":"https:\/\/aidanfinn.com\/?p=19576#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/65fde4aa9f2ab1cf1514ae320a37ec682d9398ce5791d3c2dd1e8670a71ceea0?s=96&d=mm&r=g","width":96,"height":96,"caption":"AFinn"}},{"@type":"Person","@id":"https:\/\/aidanfinn.com\/?author=1#author","url":"https:\/\/aidanfinn.com\/?author=1","name":"AFinn","image":{"@type":"ImageObject","@id":"https:\/\/aidanfinn.com\/?p=19576#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/65fde4aa9f2ab1cf1514ae320a37ec682d9398ce5791d3c2dd1e8670a71ceea0?s=96&d=mm&r=g","width":96,"height":96,"caption":"AFinn"}},{"@type":"WebPage","@id":"https:\/\/aidanfinn.com\/?p=19576#webpage","url":"https:\/\/aidanfinn.com\/?p=19576","name":"Optimize Hyper-V VM Placement To Match CSV Ownership | Aidan Finn, IT Pro","description":"This post shares a PowerShell script to automatically live migrate clustered Hyper-V virtual machines to the host that owns the CSV that the VM is stored on. The example below should work nicely with a 2-node cluster, such as a cluster-in-a-box. For lots of reasons, you get the best performance for VMs on a Hyper-V","inLanguage":"en-GB","isPartOf":{"@id":"https:\/\/aidanfinn.com\/#website"},"breadcrumb":{"@id":"https:\/\/aidanfinn.com\/?p=19576#breadcrumblist"},"author":{"@id":"https:\/\/aidanfinn.com\/?author=1#author"},"creator":{"@id":"https:\/\/aidanfinn.com\/?author=1#author"},"image":{"@type":"ImageObject","url":"https:\/\/aidanfinn.com\/wp-content\/uploads\/2015\/09\/5315.powershell_2D00_logo.gif_2D00_550x01.png","@id":"https:\/\/aidanfinn.com\/?p=19576\/#mainImage","width":550,"height":372},"primaryImageOfPage":{"@id":"https:\/\/aidanfinn.com\/?p=19576#mainImage"},"datePublished":"2016-07-05T10:32:47+01:00","dateModified":"2016-07-05T10:50:44+01:00"},{"@type":"WebSite","@id":"https:\/\/aidanfinn.com\/#website","url":"https:\/\/aidanfinn.com\/","name":"Aidan Finn, IT Pro","description":"A blog covering Azure, Hyper-V, Windows Server, desktop, systems management, deployment, and so on ...","inLanguage":"en-GB","publisher":{"@id":"https:\/\/aidanfinn.com\/#person"}}]},"og:locale":"en_GB","og:site_name":"Aidan Finn, IT Pro - A blog covering Azure, Hyper-V, Windows Server, desktop, systems management, deployment, and so on ...","og:type":"activity","og:title":"Optimize Hyper-V VM Placement To Match CSV Ownership | Aidan Finn, IT Pro","og:description":"This post shares a PowerShell script to automatically live migrate clustered Hyper-V virtual machines to the host that owns the CSV that the VM is stored on. The example below should work nicely with a 2-node cluster, such as a cluster-in-a-box. For lots of reasons, you get the best performance for VMs on a Hyper-V","og:url":"https:\/\/aidanfinn.com\/?p=19576","twitter:card":"summary","twitter:site":"@joe_elway","twitter:title":"Optimize Hyper-V VM Placement To Match CSV Ownership | Aidan Finn, IT Pro","twitter:description":"This post shares a PowerShell script to automatically live migrate clustered Hyper-V virtual machines to the host that owns the CSV that the VM is stored on. The example below should work nicely with a 2-node cluster, such as a cluster-in-a-box. For lots of reasons, you get the best performance for VMs on a Hyper-V","twitter:creator":"@joe_elway"},"aioseo_meta_data":{"post_id":"19576","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":"","og_description":"","og_object_type":"activity","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":"","og_article_tags":"","twitter_use_og":false,"twitter_card":"summary","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2020-12-21 03:53:23","updated":"2025-06-04 17:08:01","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/aidanfinn.com\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/aidanfinn.com\/?cat=20\" title=\"Hyper-V\">Hyper-V<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tOptimize Hyper-V VM Placement To Match CSV Ownership\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/aidanfinn.com\/"},{"label":"Hyper-V","link":"https:\/\/aidanfinn.com\/?cat=20"},{"label":"Optimize Hyper-V VM Placement To Match CSV Ownership","link":"https:\/\/aidanfinn.com\/?p=19576"}],"amp_enabled":true,"jetpack_featured_media_url":"https:\/\/aidanfinn.com\/wp-content\/uploads\/2015\/09\/5315.powershell_2D00_logo.gif_2D00_550x01.png","_links":{"self":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts\/19576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=19576"}],"version-history":[{"count":5,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts\/19576\/revisions"}],"predecessor-version":[{"id":19581,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts\/19576\/revisions\/19581"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/media\/18900"}],"wp:attachment":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=19576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=19576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=19576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}