MSpriya
Contributor
Contributor

Invoke-VMScript execution gives VIX error

Jump to solution

Hi,

While running a script in guest VM using Invoke-VMscript command, I am getting the following error and stack trace. I have made sure that the Invoke-VMScript command is executed after the VMwareTools are up and running in the guest VM.

Error:

Invoke-VMScript A general system error occurred: vix error codes = (1, 0).

Stack trace:

VMware.VimAutomation.ViCore.Impl.V1.Service.VmGuestServiceImpl.WaitProcessInGuest(GuestProcessManager guestProcessManager, GuestAuthentication guestAuthentication, ManagedObjectReference vmMoRef, Int64 pid)

   at VMware.VimAutomation.ViCore.Impl.V1.Service.VmGuestServiceImpl.RunScriptInGuestCore(VirtualMachineInterop vm, GuestProcessManager guestProcessManager, GuestFileManager guestFileManager, GuestAuthentication guestAuthentication, String scriptText, ScriptType scriptType, GuestProcessInfo& processInfo)

   at VMware.VimAutomation.ViCore.Impl.V1.Service.VmGuestServiceImpl.RunScriptInGuest(VirtualMachineInterop vm, String scriptText, String guestUserName, SecureString guestPassword, Int32 toolsWaitSeconds, ScriptType scriptType)

   at VMware.VimAutomation.ViCore.Impl.V1.Service.VmGuestServiceImpl.<>c__DisplayClass65_0.<RunScriptInGuest>b__0(ClientSideTask <p0>, Object <p1>)

   at VMware.VimAutomation.Sdk.Util10.Task.ClientSideTaskImpl.ThreadProc(Object obj)

The script does the following:

1. Unjoins and join the guest VM to a domain

2. Renames hostname of guest VM

Has anyone seen this error and stack trace before? Can you help me get around this issue?

Thanks,

Priya

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Yes, you have to provide station, workgroup or domain (for Windows guest OS).

I normally use pc\account or domain\account.
I also had occasions where I had to provide the account as account@domain.

You will always have to provide guest credentials afaik.
There is no default afaik.


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

View solution in original post

10 Replies
LucD
Leadership
Leadership

Are you sure your Guest CRedentials are correct?

Did that account have a profile in that Guest OS?

Do you have UAC active in that Guest OS?


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

0 Kudos
MSpriya
Contributor
Contributor

The script was invoked with Invoke-VMScript with Administrator credentials on Windows guest VM.

Yes the profile is present in the guest VM.

UAC also set to never notify.

0 Kudos
LucD
Leadership
Leadership

Can you run the same with my Invoke-VMScriptPlus function with the Verbose switch?


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

0 Kudos
MSpriya
Contributor
Contributor

LucD, Thank you for the pointer.

I did run with Invoke-VMScriptPlus but the output shows errors & stack traces from previous failed executions. Is it expected? For example, I forgot to do Import-Module of Invoke-VMScriptPlus ps1 file in the beginning. Even after doing it and then running Invoke-VMScriptPlus command with custom script, it shows previous error "Invoke-VMScriptPlus is not recognized as a cmdlet..." along with VIX error and stack trace:

PS C:\Users\Administrator> $vmName = 'windows_2k8r2_sp1_test'

$cred = New-Object System.Management.Automation.PSCredential ("user", (ConvertTo-SecureString "password" -AsPlainText -Force))

$sInvoke = @{

    VM = $vmName

    GuestCredential = $cred

    ScriptText = 'c:\temp\unjoindomain.bat'

    ScriptType = 'bat'

}

Invoke-VMScriptPlus @sInvoke

Exception calling "ListProcessesInGuest" with "3" argument(s): "A general system error occurred: vix error codes = (1, 0).

" The term 'Invoke-VMScriptPlus' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is

correct and try again.[0].Exception.Message

At C:\Users\Administrator\Desktop\VMScriptpl.ps1:623 char:1

+ Throw "$error[0].Exception.Message"

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

    + CategoryInfo          : OperationStopped: (Exception calli...ception.Message:String) [], RuntimeException

    + FullyQualifiedErrorId : Exception calling "ListProcessesInGuest" with "3" argument(s): "A general system error occurred: vix error codes = (1, 0).

    " The term 'Invoke-VMScriptPlus' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path

    is correct and try again.[0].Exception.Message

Also, I observed that when VM is unjoined from AD domain using Invoke-VMScript, it results in VIX error as above.

0 Kudos
MSpriya
Contributor
Contributor

Also, please find the output of the Invoke-VMScriptPlus command with verbose switch:

VERBOSE: 5/20/2020 8:06:27 AM Get-View Finished execution

VERBOSE: 5/20/2020 8:06:27 AM Get-View Finished execution

VERBOSE: 5/20/2020 8:06:27 AM Get-View Finished execution

VERBOSE: 5/20/2020 8:06:27 AM Get-View Finished execution

VERBOSE: No GuestOSType value provided. Trying to determine now.

VERBOSE: It's a Windows guest OS

VERBOSE: Created temp folder in guest OS C:\Users\ADMINI~1\AppData\Local\Temp\Administrator_4080vmware108

VERBOSE: Created temp script file in guest OS C:\Users\ADMINI~1\AppData\Local\Temp\Administrator_4080vmware108\Administrator_4080vmware149.cmd

VERBOSE: Created temp output file in guest OS C:\Users\ADMINI~1\AppData\Local\Temp\Administrator_4080vmware108\Administrator_4080_outputvmware143

VERBOSE: Copying Data to C:\Users\ADMINI~1\AppData\Local\Temp\Administrator_4080vmware108\Administrator_4080vmware149.cmd

VERBOSE: PUT https://172.17.9.37/guestFile?id=2283&token=52a2734b-57b5-c894-34cc-f171d1270be82283 with -1-byte payload

VERBOSE: received 33-byte response of content type

VERBOSE: Copied scripttext to temp script file

VERBOSE: Run script with 'cmd.exe  /s /c cmd > C:\Users\ADMINI~1\AppData\Local\Temp\Administrator_4080vmware108\Administrator_4080_outputvmware143 2>&1 /s /c C:\Users\ADMINI~1\AppData\Local\Temp\Administra

tor_4080vmware108\Administrator_4080vmware149.cmd'

VERBOSE: Wait for process to end

VERBOSE: Encountered a problem waiting for the script to end in the guest OS

Exception calling "ListProcessesInGuest" with "3" argument(s): "A general system error occurred: vix error codes = (1, 0).

" Exception calling "CompleteInput" with "4" argument(s): "Index was out of range. Must be non-negative and less than the size of the collection.

Parameter name: index" The specified mount name 'vmstores' is already in use. The specified mount name 'vis' is already in use.[0].Exception.Message

At C:\Users\Administrator\Desktop\VMScriptpl.ps1:623 char:1

+ Throw "$error[0].Exception.Message"

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

    + CategoryInfo          : OperationStopped: (Exception calli...ception.Message:String) [], RuntimeException

    + FullyQualifiedErrorId : Exception calling "ListProcessesInGuest" with "3" argument(s): "A general system error occurred: vix error codes = (1, 0).

" Exception calling "CompleteInput" with "4" argument(s): "Index was out of range. Must be non-negative and less than the size of the collection.

Parameter name: index" The specified mount name 'vmstores' is already in use. The specified mount name 'vis' is already in use.[0].Exception.Message

0 Kudos
MSpriya
Contributor
Contributor

LucD, Finally I was able to get around the issue by using ".\Administrator" instead of "Administrator" in Invoke-VMScript.

When script to unjoin from the domain is run with "Administrator" as GuestUser using Invoke-VMScript command, it results in VIX error. Upon enabling VMware Tools debug logs, it looks like authentication fails with Administrator user. Please refer to the attachment.

So I tried using .\Administrator in Invoke-VMScript command to explicitly login with local Administrator. This time the script execution completed fully and there were no errors.

Are you aware of this issue with domain unjoin through Invoke-VMScript?

Will VMware Tools take domain Administrator account as default account instead of local Administrator account?

0 Kudos
LucD
Leadership
Leadership

Yes, you have to provide station, workgroup or domain (for Windows guest OS).

I normally use pc\account or domain\account.
I also had occasions where I had to provide the account as account@domain.

You will always have to provide guest credentials afaik.
There is no default afaik.


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

MSpriya
Contributor
Contributor

LucD, Thank you for the information.

Also, do you have any idea why the Invoke-VMScript errors out when un-joining from domain when logged in as Administrator? I understand we have to prefix the user appropriately, but why does the existing connection break in Invoke-VMScript execution?

One more question, is there a way to setup IP address in guest VMs using domain users?

0 Kudos
LucD
Leadership
Leadership

Not really.
Did you test with a local account that is not Administrator, but is member of the local Administrators group?

Did you check if the VMware Tools service is restarted at some point?

Yes, if the account (local or domain) has local administrator authority, it should be able to change the network settings.


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

0 Kudos
MSpriya
Contributor
Contributor

One thing is that VMware tools doesn't seem to have restarted.

I shall try out the other two tasks and get back.

0 Kudos