I keep getting error messages when I run a VM deploy script Invoke-VMScript : 2020-03-18 15:34:32 Invoke-VMScript The guest operations agent could not be contacted. At C:\SCRIPTS\DEPLOY VM\Deploy-VM.ps1:200 char:1 + Invoke-VMScript -ScriptText $Add2ADGroup -VM $Hostname -GuestCredenti ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Invoke-VMScript], GuestOperationsUnavailable + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_GetProcessOutputInGuest_ViError,VMware.VimAutomation.ViCore. Cmdlets.Commands.InvokeVmScript
I have tried this to get the VM to check that VMware Tools is up and running:
Invoke-VMScript -ScriptText $Add2ADGroup -VM $Hostname -GuestCredential $VMLocalCredential
Start-Sleep -Seconds 120
Wait-Tools -VM $Hostname -TimeoutSeconds 300
It appears that Guest Operations is not available. Does the VM have vmware tools installed an running at the time you run your script?
Is port 902 open between your station and the ESXi node on which the VM is running?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
As a debugging tool, can you run the same with my Invoke-VMScriptPlus with the Verbose switch?
That function tends to give more verbose information back.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
How do I incorporate Invoke-VMScriptPlus in my script?
Copy the function and add it at the start of your script.
Then call Invoke-VMScriptPlus instead Invoke-VMScript.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
cmdlet Invoke-VMScriptPlus at command pipeline position 1
Supply values for the following parameters:
ScriptType: powershell
Exception calling "CreateTemporaryDirectoryInGuest" with "5" argument(s): "Failed to authenticate with the guest operating system using the supplied credentials."
At C:\SCRIPTS\DEPLOY VM\Deploy-VM.ps1:388 char:92
+ ... oraryDirectoryInGuest($moref, $auth, "$($env:USERNAME)_$($PID)", $nul ...
+ ~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
Exception calling "CreateTemporaryFileInGuest" with "5" argument(s): "Failed to authenticate with the guest operating system using the supplied credentials." Exception calling "CreateTemporaryDirectoryInGuest" with
"5" argument(s): "Failed to authenticate with the guest operating system using the supplied credentials."
+ FullyQualifiedErrorId : CommandNotFoundException
+ CategoryInfo : ObjectNotFound: (version:String) [], CommandNotFoundException
+ ~~~~~~~
+ version
ck the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
version : The term 'version' is not recognized as the name of a cmdlet, function, script file, or operable program. Che Cannot validate argument on parameter 'ScriptType'. The argument "Verbose" does not belong to
the set "bash;perl;python3;nodejs;php;lua;powershell;powershellv6;powershellv7;bat;exe" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.[0].Exception.Me
ssage
At C:\SCRIPTS\DEPLOY VM\Deploy-VM.ps1:409 char:1
+ Throw "$error[0].Exception.Message"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Exception calli...ception.Message:String) [], RuntimeException
+ FullyQualifiedErrorId : Exception calling "CreateTemporaryFileInGuest" with "5" argument(s): "Failed to authenticate with the guest operating system using the supplied credentials." Exception calling "Create
TemporaryDirectoryInGuest" with "5" argument(s): "Failed to authenticate with the guest operating system using the supplied credentials."
+ FullyQualifiedErrorId : CommandNotFoundException
+ CategoryInfo : ObjectNotFound: (version:String) [], CommandNotFoundException
+ ~~~~~~~
+ version
ck the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
version : The term 'version' is not recognized as the name of a cmdlet, function, script file, or operable program. Che Cannot validate argument on parameter 'ScriptType'. The argument "Verbose" does not belo
ng to the set "bash;perl;python3;nodejs;php;lua;powershell;powershellv6;powershellv7;bat;exe" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.[0].Ex
ception.Message
PS C:\SCRIPTS\DEPLOY VM>
Looks like you might have an issue with the copy/paste.
Can you attach (bottom right in the edit window) the script you are currently using?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I didn't find the function and the class definition in the script, so I added those.
I also added -ScriptTye 'powershell' -Verbose on each invocation of Invoke-VMScriptPlus
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Invoke-VMScriptPlus : Cannot bind argument to parameter 'GuestCredential' because it is null.
At C:\SCRIPTS\DEPLOY VM\script.ps1:844 char:98
+ ... powershell' -VM $Hostname -GuestCredential $VMLocalCredential -Verbos ...
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-VMScriptPlus], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Invoke-VMScriptPlus
That is not really my problem to solve.
Apparently the $VMLocalCredential variable is empty.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference