Skip to content

Instantly share code, notes, and snippets.

@lamw
Created November 20, 2015 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lamw/7135a7ef3e8efb7913d8 to your computer and use it in GitHub Desktop.
Save lamw/7135a7ef3e8efb7913d8 to your computer and use it in GitHub Desktop.
Listing all vSphere DRS Rules that have been defined for a VM
$clusterName = "VSAN-Cluster"
$cluster = Get-Cluster -Name $clusterName
$vms = Get-View ($cluster| Get-VM)
$cluster_view = Get-View ($cluster)
foreach ($vm in $vms) {
# Using new vSphere 6.0 API (http://www.virtuallyghetto.com/2015/02/handy-new-vsphere-6-0-apis-to-be-aware-of.html)
$cluster_view.FindRulesForVm($vm.MoRef)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment