Automation

 View Only
  • 1.  how to get the VM Name in the below script

    Posted Aug 05, 2024 08:06 PM

    Hi,

    Please help me, how to get the VM Name in the below script, since we have started using containers, I would like to know, which volumes are mapped to VM. 

    Please help

    Get-CnsVolume | select Name, @{N='CapacityGB';E={[math]::round($_.CapacityMB/1024)}}, Datastore, @{N='EntityType';E={$_.Metadata.CnsEntityMetadata.EntityType}}, @{N='KubernetesClusterId';E={$_.Metadata.CnsEntityMetadata.KubernetesClusterId}}, @{N='Namespace';E={$_.Metadata.CnsEntityMetadata.Namespace}}, @{N='Label';E={$_.Metadata.CnsEntityMetadata.Label}}, @{N='Path';E={$_.ExtensionData.backingobjectdetails.BackingDiskPath}} | ft -auto



  • 2.  RE: how to get the VM Name in the below script

    Posted Aug 06, 2024 02:59 PM

    To map the PVC to a VM, query the Kubernetes API, or use the kubectl command.
    If the VM is directly related to the PVC the $_.Metadata.EntityMetadata.The entityName property will give you the VM's name.
    But it depends on your setup.



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


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


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



  • 3.  RE: how to get the VM Name in the below script

    Posted Aug 07, 2024 01:24 AM

    Hi LucD, 

    I tried as you mentioned but it is showing blank.

    Get-CnsVolume | select @{N='VM_Name';E={$_.Metadata.EntityMetadata}}, Name, @{N='CapacityGB';E={[math]::round($_.CapacityMB/1024)}}, Datastore, @{N='EntityType';E={$_.Metadata.CnsEntityMetadata.EntityType}}, @{N='KubernetesClusterId';E={$_.Metadata.CnsEntityMetadata.KubernetesClusterId}}, @{N='Namespace';E={$_.Metadata.CnsEntityMetadata.Namespace}}, @{N='Label';E={$_.Metadata.CnsEntityMetadata.Label}}, @{N='Path';E={$_.ExtensionData.backingobjectdetails.BackingDiskPath}} | ft -auto

    the same I can see through vCenter, but I need that VM Name in the CLI




  • 4.  RE: how to get the VM Name in the below script

    Posted Aug 09, 2024 10:41 AM

    @LucD

    Any luck with this. Please assist.