VMware Cloud Community
AymanSammour
Contributor
Contributor

Invoke-VMScript

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

0 Kudos
16 Replies
LucD
Leadership
Leadership

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?


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

0 Kudos
AymanSammour
Contributor
Contributor

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

0 Kudos
LucD
Leadership
Leadership

Looks like the formatting of your reply got a bit scrambled


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

0 Kudos
LucD
Leadership
Leadership

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?


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

0 Kudos
AymanSammour
Contributor
Contributor

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  

0 Kudos
LucD
Leadership
Leadership

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


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

0 Kudos
AymanSammour
Contributor
Contributor

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 

0 Kudos
AymanSammour
Contributor
Contributor

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

any idea why?

0 Kudos
LucD
Leadership
Leadership

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


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

0 Kudos
AymanSammour
Contributor
Contributor

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  

0 Kudos
LucD
Leadership
Leadership

Are you using Invoke-VMScriptPlus with the Verbose switch?


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

0 Kudos
AymanSammour
Contributor
Contributor

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

0 Kudos
LucD
Leadership
Leadership

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


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

0 Kudos
AymanSammour
Contributor
Contributor

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 

 

0 Kudos
LucD
Leadership
Leadership

Did the execution of the script work?


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

0 Kudos
AymanSammour
Contributor
Contributor

yes it did, thank you for your support 

0 Kudos