Automation

 View Only
  • 1.  Using RVTools to Move Zombie Folders instead of just VMDK

    Broadcom Employee
    Posted Feb 15, 2023 06:00 PM

    Following:  https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/is-it-possible-to-move-the-Zombie-file-from-specified-path-to/m-p/2954251#M110731

     I hope it was ok to start a new post instead of taking over the initial one listed above.  What change would you make to move the directory folder where the zombie VMDKs are living, trying to do a clean up script and the original one works but leaves the folder with all the other files still there.  Am I right in thinking it'd be around:

    Get-Content -Path $file |
    ConvertFrom-Csv |
    Where-Object {($_.Message -match 'Possibly a Zombie vmdk file') -and ($_.Name -notmatch 'cp-replica-') -and ($_.Name -notmatch 'appvolumes') -and ($_.Name -notmatch 'contentlib')} |
    Group-Object -Property {$_.Name.Split(']')[0].Trimstart('[')} | %{
    Write-Host "Looking at datastore $($_.Name)"
    $ds = Get-Datastore -Name $_.Name

    I just cannot get the correct syntax to see the folder instead of the VMDK.  The last step would Move-Item still work in this case to move a whole directory?

    Thanks!



  • 2.  RE: Using RVTools to Move Zombie Folders instead of just VMDK

    Posted Feb 15, 2023 08:03 PM

    First, yes, the Move-Item cmdlet can move a complete folder with all the files in it.

    But I just noticed that this script is not really correct.
    You can't copy a VMDK with the Move-Item cmdlet.
    A VMDK consists of 2 files, and with Move-Item the script actually only copies one of those 2 files.

    But coming back to your request, do you actually want to move the complete folder that contains a zombie VMDK?
    There could be situations where the VM is valid but only 1 VMDK is a zombie VMDK



  • 3.  RE: Using RVTools to Move Zombie Folders instead of just VMDK

    Broadcom Employee
    Posted Feb 15, 2023 08:28 PM

    That's a good point.  Would it be able to move the folder if the VMDK or VMX is registered to a VM?



  • 4.  RE: Using RVTools to Move Zombie Folders instead of just VMDK
    Best Answer

    Posted Feb 15, 2023 08:43 PM

    There might be a lock on one or more of the files of an active VM, but the other files would be moved and hence the VM would become unusable (possibly after a power off/power on) I'm afraid.

    Moving one or more orphaned VMDK in a VM is possible, just not with Move-Item but with Copy-DatastoreItem.
    Moving a complete folder would need to verify that the VM is not in use anymore (registered).
    Also when moving a complete VM's folder, the VMDK would in any case need to be handled differently (since Move-Item doesn't keep the integrity of the VMDK).

    If there is an actual need to move the complete folder, and keep the VMDK integrity, it would be best if I start a completely new script.



  • 5.  RE: Using RVTools to Move Zombie Folders instead of just VMDK

    Broadcom Employee
    Posted Feb 21, 2023 07:20 PM

    Not sure why I didn't just search "lucd vmware delete orphaned files" because your script pulled up from 2015.

      https://github.com/voletri/PowerCLI-1/blob/master/Remove-Orphaned-Files.ps1

    I may give this a try versus what I've been building out using RVTools, I kind of like using RVTools as it will generate a visual look at the Zombie VMs and provide a CSV file that can be edited beforehand.

    Again thank you  !