Automation

 View Only
Expand all | Collapse all

Invoke-VMScript

  • 1.  Invoke-VMScript

    Posted Aug 18, 2022 09:35 AM

    Hi,

    I have built full automatic deployment application using a mixer of PowerShell and PowerCLI

    My environment consists of 8 vCenters, 2 of which are in a different domain and a different country (link speed 8 Mg).

    I can log on the vCenters on my remote site, and I can execute commands normal, but when I use the Invoke-VMScript, sometimes I get a

    1-warning message “WARNING: The version of VMware Tools on VM 'vm**name' is out of date and may cause Invoke-VMScript to work improperly. ”

    2- other times I got nothing, and sometimes I get an error “ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_DownloadFileFromGuest_DownloadError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript”

    3- other time the progress bar appears and I get nothing

     

    PowerCLI version VMware.PowerCLI 12.5.0 build 19195797

    vCenter version Version:7.0.3

    ports 443, and 902 from the automation server to the ESXi hosts



  • 2.  RE: Invoke-VMScript

    Posted Aug 18, 2022 09:41 AM

    From where to where do you use the Invoke-VMScript?
    Did you check the logs of the VMware Tools?
    Can you enable debug mode for the VMware Tools?

    Are you ever going to reply on some of the other threads you started in this community?



  • 3.  RE: Invoke-VMScript

    Posted Aug 18, 2022 10:34 AM

    From where to where do you use the Invoke-VMScript? The Invoke-VMScript executed on the automation server Did you check the logs of the VMware Tools? I cannot see any issues Can you enable debug mode for the VMware Tools? I have enabled the debug mode [2022-08-18T10:22:20.218Z] [ message] [vix] [3216] VixToolsListProcessesEx: opcode 186 returning 0 [2022-08-18T10:22:25.420Z] [ message] [vix] [3216] VixTools_ProcessVixCommand: command 186 [2022-08-18T10:22:25.451Z] [ message] [vix] [3216] VixToolsListProcessesEx: opcode 186 returning 0 [2022-08-18T10:22:30.655Z] [ message] [vix] [3216] VixTools_ProcessVixCommand: command 186 [2022-08-18T10:22:30.686Z] [ message] [vix] [3216] VixToolsListProcessesEx: opcode 186 returning 0 [2022-08-18T10:22:35.874Z] [ message] [vix] [3216] VixTools_ProcessVixCommand: command 186 Are you ever going to reply on some of the other threads you started in this community? Apologies on my behalf I will update the threads I have started



  • 4.  RE: Invoke-VMScript

    Posted Aug 18, 2022 11:10 AM

    Looks like the formatting of your reply got a bit scrambled



  • 5.  RE: Invoke-VMScript

    Posted Aug 18, 2022 11:17 AM

    I was able to look at that log extract.
    Are you sure you used KB1007873 to enable debugging?
    That extract looks like normal messages, not debug ones.

    Also, what did you actually run with Invoke-VMScript at that time?
    And what kind of error did Invoke-VMScript return?



  • 6.  RE: Invoke-VMScript

    Posted Aug 20, 2022 10:28 AM

    Juts tried  another scenario, I have logged in the other domain and I ran the same invoke statement, and it did work, !

    that would lead me to  believe, even though port 902, and 443 are open there is network issue. 

    Tomorrow I  will investigate further, and keep you posted  



  • 7.  RE: Invoke-VMScript

    Posted Aug 20, 2022 04:02 PM

    You could try with my Invoke-VMScriptPlus function with the Verbose switch.
    That gives more info on the different steps.



  • 8.  RE: Invoke-VMScript

    Posted Aug 21, 2022 08:32 AM
      |   view attached

    network came back with no dropped and denied Packets.
    I have attached the log files from the vmtools
    Just to reiterate the scenario explained below

    Source                                                          Destination

    Automation Server                                       $vCentre

    Domain X                                                    Domain Y

     

    From the automation server I can provision a new server in destination vCenter, and works with no issues.

    Running any Invoke-VMScript, I get the result below.

    command

    Invoke-VMScript -vm $vmname -ScriptText  {Get-service} -ScriptType Powershell -Server $vCentre -GuestUser "Domain\abcef" -GuestPassword "XXXXX"

    Result

    WARNING: The version of VMware Tools on VM 'vmname' is out of date and may cause Invoke-VMScript to work improperly.

    Invoke-VMScript : 21/8/2022 10:03:27         Invoke-VMScript                     An error occurred while sending the request.    

    At line:1 char:1

    + Invoke-VMScript -vm $vmname -ScriptText  {Get-service} -ScriptType Po ...

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : NotSpecified: (:) [Invoke-VMScript], ViError

        + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_DownloadFileFromGuest_DownloadError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript

     

    i will run the Invoke-VMScriptPlus and let you know 

    Attachment(s)

    log
    vmusr1.log   58 KB 1 version


  • 9.  RE: Invoke-VMScript

    Posted Aug 21, 2022 08:39 AM

    Invoke-VMScriptPlus asks fro the vcentre credential even though the my $global:DefaultVIServer is set and authenticated with the correct vCenter !

    any idea why?



  • 10.  RE: Invoke-VMScript

    Posted Aug 21, 2022 09:36 AM

    Did you add the Verbose switch?
    I would need to see the complete message you are getting.



  • 11.  RE: Invoke-VMScript

    Posted Aug 22, 2022 07:31 AM

    i have added the loglevel=verbose to the VMware VGAuth , and to the tools.conf log file, and restarted the vmtools service, still getting the debug, i can not see any verbose  messages  



  • 12.  RE: Invoke-VMScript

    Posted Aug 22, 2022 08:42 AM

    Are you using Invoke-VMScriptPlus with the Verbose switch?



  • 13.  RE: Invoke-VMScript

    Posted Aug 22, 2022 09:29 AM

    Invoke-VMScriptPlus : Cannot process argument transformation on parameter 'Server'. Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    At line:1 char:92
    + ... ptText {Get-service} -ScriptType powershell -Server $vCentre -GuestU ...
    + ~~~~~~~~
    + CategoryInfo : InvalidData: (:) [Invoke-VMScriptPlus], ParameterBindingArgumentTransformationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Invoke-VMScriptPlus



  • 14.  RE: Invoke-VMScript

    Posted Aug 22, 2022 10:28 AM

    The Server parameter expects a VIServer object, not a string.
    The default is $global:DefaultVIServer



  • 15.  RE: Invoke-VMScript

    Posted Aug 22, 2022 11:31 AM

    that worked, thanks, 

    the result of Invoke-VMScriptPlus " The remote name could not be resolved 'vmhost'

    to resolve the the issue i added all hosts and IP addresses in automation server local host file 

     



  • 16.  RE: Invoke-VMScript

    Posted Aug 22, 2022 11:54 AM

    Did the execution of the script work?



  • 17.  RE: Invoke-VMScript

    Posted Aug 23, 2022 04:14 AM

    yes it did, thank you for your support