Automation

 View Only
  • 1.  New-HardDisk command issue with vmdk snapshot file

    Posted Nov 05, 2024 04:11 AM

    I created a PowerShell script to search the datastore for VMs with snapshots. These VMs are not registered in vCenter, so I can't use the Get-Snapshot command. However, the script works by reading the disk path, opening the VMX file, and identifying which snapshot is in use. I then pass this path to the New-HardDisk command to attach the snapshot to one of my live VMs.

    The problem arises when I execute the New-HardDisk command, my ESXi host immediately disconnects from vCenter, and all datastores and VMs are marked as disconnected or inaccessible. Interestingly, if I manually attach the same VMDK from the vCenter console, there are no disconnection or inaccessibility issues.

    The command for attaching the VMDK file is:
    New-HardDisk -DiskPath "[NFS_2] WIN-NFS2-01/WIN-NFS2-01-000001.vmdk" -VM $myVM

    From the vCenter console, I can open the datastore, navigate to the folder WIN-NFS2-01, select the file WIN-NFS2-01-000001.vmdk, and everything works fine.

    Does anyone know what might be causing the disconnection or inaccessibility issue when I use the PowerShell command?



  • 2.  RE: New-HardDisk command issue with vmdk snapshot file

    Posted Nov 05, 2024 11:14 AM

    If the process works in the web client and not with PowerCLI I suggest opening an SR



    ------------------------------


    Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference


    ------------------------------



  • 3.  RE: New-HardDisk command issue with vmdk snapshot file

    Posted Nov 06, 2024 02:32 AM

    Yes, I can attach a VMDK snapshot from the web client without issue, but when I try to do it from PowerCLI, an error occurs. vCenter briefly disconnects from the ESXi host for 5-10 seconds, and then everything returns to normal. Tested with vCenter 7.x and 8.x. Anyway, I will open SR.