1 2 3 Previous Next 35 Replies Latest reply on Aug 9, 2018 1:46 PM by LucD Go to original post
      • 30. Re: Can a PowerCLI script display a prompt on a Guest OS?
        emcclure Enthusiast

        Hi LucD,


        So I ran the script from my desktop machine and get this:


        Resolve-DnsName : ip.removed.in-addr.arpa : DNS name does not exist
        At C:\Users\emcclure\Desktop\test.ps1:237 char:19
        +       $hostName = Resolve-DnsName -Name $ip | Select-Object -ExpandPr ...
        +                   ~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : ResourceUnavailable: (ip.removed.in-addr.arpa:String) [Resolve-DnsName], Win32Excepti
            + FullyQualifiedErrorId : DNS_ERROR_RCODE_NAME_ERROR,Microsoft.DnsClient.Commands.ResolveDnsName

        Invoke-WebRequest : Cannot bind parameter 'Uri'. Cannot convert value
        "https://:443/guestFile?id=197&token=52cfa257-a30a-19ea-d060-af7c849421d1197" to type "System.Uri". Error: "Invalid
        URI: The hostname could not be parsed."
        At C:\Users\emcclure\Desktop\test.ps1:239 char:44
        +       $copyResult = Invoke-WebRequest -Uri $filePath -Method Put -Bod ...
        +                                            ~~~~~~~~~
            + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
            + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

        ScripText copy failed!Status
        At C:\Users\emcclure\Desktop\test.ps1:241 char:9
        +         Throw "ScripText copy failed!`rStatus $($copyResult.StatusCod ...
        +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : OperationStopped: (ScripText copy failed!Status  :String) [], RuntimeException
            + FullyQualifiedErrorId : ScripText copy failed!Status


        I figured it's in a different location, so let's use a machine that's in the same location that's on the same vCenter server.  So I ran it from there (with the proper creds) and nothing.  It appears to run, doesn't give me any errors or any output, just goes to the next line in PowerCLI as if it's all good.  I figure I'll try running it in PowerShell on that same machine and all I get is this:


        Unable to find type [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine].
        At C:\Users\emcclure\Desktop\test.ps1:117 char:5
        +     [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]] ...
        +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : InvalidOperation: (VMware.VimAutom....VirtualMachine:TypeName) [], RuntimeException
            + FullyQualifiedErrorId : TypeNotFound

        You cannot call a method on a null-valued expression.
        At C:\Users\emcclure\Desktop\test.ps1:440 char:1
        + $result = Invoke-VMScriptPlus @sInvP
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
            + FullyQualifiedErrorId : InvokeMethodOnNull


        So what am I missing?  I should be able to run this from anywhere right and it should just work?  It should be able to find the machine in the vCenter and run the script?  For the creds I'm using the local administrator account, so that shouldn't be a problem as far as permissions go.

        • 31. Re: Can a PowerCLI script display a prompt on a Guest OS?
          LucD Guru
          Community WarriorsvExpertUser Moderators

          Looks like DNS resolution doesn't work on the machine where you call the Invoke-VMScriptPlus function.

          The function replaces the IP in the URI (for the script upload to the VM's guest OS) returned by Guest Operations.

          This is done to avoid certificate errors on the HTTPS connection

          • 32. Re: Can a PowerCLI script display a prompt on a Guest OS?
            emcclure Enthusiast

            Ok, I'm not sure why DNS resolution would not work on the machine I'm typing this from as I can go anywhere on the internet, access internal resources by dns name, etc without issue.  When I run the script from a machine that's in the same subnet and location as the target machine though the script just runs, but that's it.  Nothing appears on the target machine.  I've even disabled AV to make sure that wasn't causing a problem.  Windows firewall is off as well, so this makes no sense to me as to why it's not working.  This is rather confusing and I was hoping this would work, but I just don't understand why it's working for you and not for me.

            • 33. Re: Can a PowerCLI script display a prompt on a Guest OS?
              LucD Guru
              vExpertCommunity WarriorsUser Moderators

              The DNS name resolution is required to translate the IP address in the URI returned by the Guest Operations.
              That URI is used to upload the script, via the ESXi node, to the VM.

              In your output it looks like the name resolution of the IP address of the ESXi node on which the target VM is running, doesn't work.

              All subsequent errors are a consequence of this 1st error.


              You can check if this returns anything on your station



              $ip = "<IP-addr-Of-ESXi-node-on-which VM-runs>"

              Resolve-DnsName -Name $ip

              • 34. Re: Can a PowerCLI script display a prompt on a Guest OS?
                emcclure Enthusiast

                Hi LucD,


                Looking at this page: Invoke-VMScriptPlus v2 - LucD notes  do I need to be using PowerShell v6.0.2?  I think I'm running 5.1 right now.  If so where did you download it exactly so I can use the same version?



                1 2 3 Previous Next