2 Replies Latest reply on Dec 27, 2019 12:05 AM by LucD

    Getting VsphereVM name

    MayuriJ87 Lurker

      Is there any better way to get the vsphereVM name. I am following the below approach,

       

          $vmrdweb = Get-vspherevmname -vmname $Rdwebname -org $NewOrg.Name -vapp $vapp.Name -CIServer $global:DefaultCIServers.Name -CISessionId $global:DefaultCIServers.sessionid -VIserver $global:DefaultVIServer.Name -VIsessionid $global:DefaultVIServer.SessionId

       

      Inside the Get-vspherevmname function , I have written below block of code,

       

            Set-PowerCLIConfiguration -DisplayDeprecationWarnings $false -Confirm:$false | Out-Null

               

                  $ciconnect = Connect-CIServer -Server $ciserver -Session $cisessionid

                 

                 do { $vma = Get-CIVM -Org $org -VApp $vapp -Name $vmname

                 Start-Sleep -Seconds $3Seconds   

                  $vmconf = $vma.ExtensionData           

                  $vmtype = $vma.ExtensionData.Type

                  $vma = Get-CIVM -Org $org -VApp $vapp -Name $vmname

                  Start-Sleep -Seconds $5Seconds

                  $vmConfUri = $vma.ExtensionData.Href

                  $webclient = New-Object system.net.webclient -ErrorAction stop

                  $webclient.Headers.Add('x-vcloud-authorization',$vmConf.Client.SessionKey)

                  Start-Sleep -Seconds $3Seconds

                  $webclient.Headers.Add('accept',$vmType + ";version=$($APIVersion)")

                  Start-Sleep -Seconds 15

                  [xml]$vmConfXML = $webclient.DownloadString($vmConfUri)

       

      This approach seems to be failing as it takes longer in generating Uri and it fails to extract the vm name. Is there any better approach ?