PowerCLI

 View Only
  • 1.  VMs with VMDK disks split among datastores

    Posted Sep 05, 2019 12:08 PM

    Anyone have an existing script that will only output VMs with VMDK disks not all on one datastore?  This storage DRS 'keep VMDK disks together' checkbox got undone in our environment and disks were moved all over the map.

    thanks



  • 2.  RE: VMs with VMDK disks split among datastores

    Posted Sep 05, 2019 01:43 PM

    Would this help?

    Get-VM | where{$_.DatastoreIdList.Count -gt 1}



  • 3.  RE: VMs with VMDK disks split among datastores

    Posted Sep 05, 2019 02:08 PM

    Thanks LucD, I started down that path but the 'get-datastore' commandlet includes mounted ISO's and not seeing a property to exempt on

    came up with the below, it's ugly but seems to work

    find vmx registration datastore name:

    $VM = get-vm xxxx | select Name,@{N="VMPath";E={$_.ExtensionData.Config.Files.VmPathName}}

    $diskreal = $VM.VMPath

    $diskfinal = $diskreal.Split( )[0]

    get VM harddisks and compare to vmx registration path:

    get-harddisk -vm $VM.name | foreach-object {

    $harddiskreal = $_.Filename

    $harddiskfinal = $harddiskreal.split( )[0]

    if ("$harddiskfinal" -ne "$diskfinal") {write-host $harddiskreal is on different datastore than $diskreal}

    }

    now to clean it up



  • 4.  RE: VMs with VMDK disks split among datastores

    Posted Sep 05, 2019 02:25 PM

    If SDRS is active, the affinity rule should correct the situation.