Invoke-VMScript has stopped working from past couple days. The same VM has been working from past few months. But now when I run any Invoke-VMScript command, Invoke-VMScript: 6/24/2020 1:21:39 PM Invoke-VMScript A general system error occurred: vix error codes = (1, 0). Error is getting displayed
Sample command:
$Command_text="dir C:\users\"
Invoke-VMScript -VM $TARGET_VM -ScriptText $Command_text -GuestUser $vm_user -GuestPassword '&rWn.
Based on the previous posts, I tried following things:
Here is the vmware.log excerpt:
2020-06-24T13:51:29.022Z| vcpu-0| I125: TOOLS autoupgrade protocol version 2
2020-06-24T13:51:29.022Z| vcpu-0| I125: Vix: [mainDispatch.c:4156]: VMAutomationReportPowerStateChange: Reporting power state change (opcode=2, err=0).
2020-06-24T13:51:29.022Z| vcpu-0| I125: TOOLS Received tools.set.version rpc call, version = 10304, setting type to 1 from guest OS
2020-06-24T13:51:29.022Z| vcpu-0| I125: Tools_SetVersionAndType did nothing; new tools version (10304) and type (1) match old Tools version and type
2020-06-24T13:53:50.874Z| vmx| I125: VigorTransportProcessClientPayload: opID=f0c9f8f-2e-0c76 seq=29344: Receiving GuestOps.CreateTemporaryFile request.
2020-06-24T13:53:51.023Z| vcpu-1| I125: VigorTransport_ServerSendResponse opID=f0c9f8f-2e-0c76 seq=29344: Completed GuestOps request with messages.
Please suggest.
You're welcome.
Btw, when I experience an AD authentication issue, I most of the time start with checking the secure channel (see the Test-ComputerSecureChannel cmdlet).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Did you already try adding the Verbose switch to the Invoke-VMScript cmdlet?
Can you also try adding the parameter -ScriptType Bat, on a Windows Guest OS the default is PowerShell.
As an alternative try my Invoke-VMScriptPlus with the Verbose option.
That function tends to provide a bit more information.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD
Adding verbose and -ScriptType Bat, didn't help much. This is the output:
VERBOSE: Performing the operation "Invoke-VMScript" on target "QA-CICD-Win10-64
VERBOSE: 6/24/2020 3:14:53 PM Invoke-VMScript Finished execution
Invoke-VMScript: 6/24/2020 3:15:15 PM Invoke-VMScript A general system error occurred: vix error codes = (1, 0).
As you suggested, tried Invoke-VMScriptPlus
$credVM = Get-VICredentialStoreItem -Host $vmName
$cred = New-Object System.Management.Automation.PSCredential ($vm_user, (ConvertTo-SecureString $vm_pass -AsPlainText -Force))
$sInvoke = @{
VM = $vmName
GuestCredential = $cred
ScriptText = 'dir C:\users\'
ScriptType = 'bash'
}
Invoke-VMScriptPlus @sInvoke
Output:
Invoke-VMScriptPlus: VMware Tools are not running on VM.
But VMWare Tools is installed in the VM, here is the screenshot.
Tried the Invoke-VMScriptPlus with the Verbose option, this is the output I see:
PS /Users/sgaikwad> Invoke-VMScriptPlus @sInvoke -Verbose
VERBOSE: 6/24/2020 4:04:19 PM Get-View Finished execution
VERBOSE: 6/24/2020 4:04:19 PM Get-View Finished execution
VERBOSE: 6/24/2020 4:04:19 PM Get-View Finished execution
VERBOSE: 6/24/2020 4:04:19 PM Get-View Finished execution
VERBOSE: No GuestOSType value provided. Trying to determine now.
VERBOSE: It's a Windows guest OS
VERBOSE: Invalid scripttype provided
Invoke-VMScriptPlus: For a Windows guest OS the ScriptType can be Bat, PowerShell, PowerShellv6 or PowerShellv7
MethodInvocationException: /Users/sgaikwad/Invoke-VMScriptPlus V3.ps1:438
Line |
438 | … oraryDirectoryInGuest($moref, $auth, "$($env:USERNAME)_$($PID)", $nul …
| ~~~~
| Exception calling "CreateTemporaryDirectoryInGuest" with "5" argument(s): "A general system error occurred: vix error codes = (1, 0). "
VERBOSE: Created temp folder in guest OS
VERBOSE: Encountered a problem creating the script file in the guest OS
Exception: /Users/sgaikwad/Invoke-VMScriptPlus V3.ps1:459
Line |
459 | Throw "$error[0].Exception.Message"
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "CreateTemporaryFileInGuest" with "5" argument(s): "A general system error occurred: vix error codes = (1, 0). " Exception calling "CreateTemporaryDirectoryInGuest" with "5" argument(s): "A general system error occurred: vix error codes
| = (1, 0). " For a Windows guest OS the ScriptType can be Bat, PowerShell, PowerShellv6 or PowerShellv7 A parameter cannot be found that matches parameter name 'Veerbose'. VMware Tools are not running on VM QA-CICD-Win10-64 Cmdlet
| Get-VICredentialStoreItem is not supported on PowerShell Core. Cannot process argument transformation on parameter 'GuestPassword'. Cannot convert the "&rWnh[Uyw38nYjhu" value of type "System.String" to type "System.Security.SecureString".
| System.Management.Automation.ParseException: At line:1 char:1 + . + ~ Missing expression after '.' in pipeline element. at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at
| System.Management.Automation.Runspaces.Pipeline.Invoke() at Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception& exceptionThrown, ExecutionOptions options) 6/24/2020 3:15:43 PM Invoke-VMScript A general system error
| occurred: vix error codes = (1, 0). 6/24/2020 3:15:15 PM Invoke-VMScript A general system error occurred: vix error codes = (1, 0). The term 'Test-InvokeVMScript' 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. 6/24/2020 1:21:39 PM Invoke-VMScript A general system error occurred: vix error codes = (1, 0). 6/24/2020 1:21:23 PM Invoke-VMScript A general
| system error occurred: vix error codes = (1, 0). 6/24/2020 1:21:07 PM Invoke-VMScript Timeout error while waiting for VMware Tools to start in the guest. 6/24/2020 9:53:51 AM Invoke-VMScript A general system error occurred: vix error codes = (1, 0).
| 6/22/2020 2:26:35 PM Invoke-VMScript Server vcenter.nyoffice.company.com is not connected. 6/22/2020 11:53:51 AM Invoke-VMScript A general system error occurred: vix error codes = (1, 0). 6/22/2020 11:53:40 AM Invoke-VMScript Value cannot be found for
| the mandatory parameter VM 6/20/2020 10:24:34 PM Invoke-VMScript A general system error occurred: vix error codes = (1, 0). 6/20/2020 10:24:05 PM Invoke-VMScript A general system error occurred: vix error codes = (1, 0). 6/20/2020 3:58:07 PM
| Invoke-VMScript A general system error occurred: vix error codes = (1, 0). Cannot bind parameter 'ScriptType'. Cannot convert value "=" to type "VMware.VimAutomation.ViCore.Types.V1.ScriptType". Error: "Unable to match the identifier name = to a valid
| enumerator name. Specify one of the following enumerator names and try again: Powershell, Bat, Bash" 6/19/2020 5:23:56 PM Invoke-VMScript Value cannot be found for the mandatory parameter VM System.Management.Automation.ParseException: At line:1 char:7
| + $ECHO $Command_text + ~~~~~~~~~~~~~ Unexpected token '$Command_text' in expression or statement. at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at System.Management.Automation.Runspaces.Pipeline.Invoke()
| at Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception& exceptionThrown, ExecutionOptions options) System.Management.Automation.ParseException: At line:1 char:7 + $ECHO $Command_text + ~~~~~~~~~~~~~ Unexpected token
| '$Command_text' in expression or statement. at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at System.Management.Automation.Runspaces.Pipeline.Invoke() at
| Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception& exceptionThrown, ExecutionOptions options) System.Management.Automation.ParseException: At line:1 char:7 + $ECHO $Command_text + ~~~~~~~~~~~~~ Unexpected token
| '$Command_text' in expression or statement. at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at System.Management.Automation.Runspaces.Pipeline.Invoke() at
| Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception& exceptionThrown, ExecutionOptions options) 6/19/2020 4:28:51 PM Invoke-VMScript A general system error occurred: vix error codes = (1, 0). 6/19/2020 4:16:40 PM
| Invoke-VMScript A general system error occurred: vix error codes = (1, 0). 6/19/2020 4:14:46 PM Invoke-VMScript A general system error occurred: vix error codes = (1, 0). 6/19/2020 4:14:24 PM Invoke-VMScript A general system error occurred: vix
| error codes = (1, 0). A positional parameter cannot be found that accepts argument 'True'. A positional parameter cannot be found that accepts argument 'True'. A positional parameter cannot be found that accepts argument 'true'. A positional parameter
| cannot be found that accepts argument 'True'. Cannot bind parameter 'ScriptType'. Cannot convert value "=" to type "VMware.VimAutomation.ViCore.Types.V1.ScriptType". Error: "Unable to match the identifier name = to a valid enumerator name. Specify one of
| the following enumerator names and try again: Powershell, Bat, Bash" 6/18/2020 10:28:05 PM Copy-VMGuestFile Cannot complete the operation because the file or folder C:\Users\qa.XRAY\RegisterAppiumNodeTask.ps1 already exists 6/18/2020 10:18:34 PM
| Copy-VMGuestFile The guest operations agent could not be contacted. Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.
| Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided. Parameter set cannot be resolved using the specified named parameters. One
| or more parameters issued cannot be used together or an insufficient number of parameters were provided. Cannot bind parameter because parameter 'ScriptText' is specified more than once. To provide multiple values to parameters that can accept multiple
| values, use the array syntax. For example, "-parameter value1,value2,value3". Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were
| provided. 6/18/2020 3:25:54 PM Invoke-VMScript Failed to authenticate with the guest operating system using the supplied credentials. The term 'New-JobTrigger' 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. The term 'New-ScheduledTaskAction' 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. 6/17/2020 5:04:46 PM Invoke-VMScript SSPI is not supported on Unix OS. [0].Exception.Message
Looks like you specified ScriptType = 'bash' instead of 'bat' on the Invoke-VMScriptPlus call
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I got the same output:
$cred = New-Object System.Management.Automation.PSCredential ($vm_user, (ConvertTo-SecureString $vm_pass -AsPlainText -Force))
$sInvoke = @{
VM = $vmName
GuestCredential = $cred
ScriptText = 'dir C:\users\'
ScriptType = 'bat'
}
Invoke-VMScriptPlus @sInvoke
VERBOSE: 6/24/2020 5:35:25 PM Get-View Finished execution
VERBOSE: 6/24/2020 5:35:25 PM Get-View Finished execution
VERBOSE: 6/24/2020 5:35:25 PM Get-View Finished execution
VERBOSE: 6/24/2020 5:35:25 PM Get-View Finished execution
Invoke-VMScriptPlus: VMware Tools are not running on VM VMName
But as I mentioned in the earlier VMware Tools was already installed. I also tried restarting the 'VMWare Tools' service but I was getting the same error.
--------
I was running 'Invoke-VMScriptPlus' from Mac so I switched to Windows OS but looks like the script is looking for VIX\VixCOM.dll which was not available.
So I installed 'VMware-VIX-1.14.0-2306114.exe' from https://my.vmware.com/group/vmware/downloads/get-download?downloadGroup=VIXAPI114
But 'VMware-VIX-1.14.0-2306114.exe' got installed in C:\Program Files (x86)\VMware\VMware VIX location and script is still complaining that it is not able to find VIX\VixCOM.dll
I see that there are latest versions of 'vmware vix api' available but all the links throw below message. Only VIXAPI114 worked.
Please suggest.
Does the Guest OS account you are using have a profile in the Guest OS?
In other words, did you ever logon with that account in the Guest OS?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, it is an old VM, I almost login to it everyday.
For one reason or another, the Invoke-VMScriptPlus function doesn't seem to be able to create a temporary folder (in which the script and script output will be stored).
That folder is created in the temporary folder ($env:Temp) of the user that is defined in the GuestCredential.
Just to make sure, can you create a folder in $env:Temp for that user when logged into the Guest OS?
Otherwise, you should perhaps consider using debug logging for VMware Tools on that VM.See KB1007873.
That might provide some additional information.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Can you please let me know the path $env? I tried creating Temp directory in Home directory and C:\Windows it worked as the user I'm logging in with is a domain admin.
Turned on the debug logging for VMWare tools, looks like additional logs are getting displayed now.
This is the error logs for Invoke-VMScriptPlus function:
2020-06-25T15:58:57.956Z| vcpu-2| I125: GuestRpc: Reinitializing Channel 1(toolbox)
2020-06-25T15:59:00.517Z| vmx| I125: Guest: toolbox: Version: build-7253323
2020-06-25T15:59:00.517Z| vcpu-1| W115: GuestRpc: application toolbox, changing channel 65535 -> 0
2020-06-25T15:59:00.517Z| vcpu-1| I125: GuestRpc: Channel 0, guest application toolbox.
2020-06-25T15:59:00.517Z| vcpu-1| I125: DEPLOYPKG: ToolsDeployPkg_Begin: state=0 err=0, msg=null
2020-06-25T15:59:00.527Z| vmx| I125: TOOLS autoupgrade protocol version 2
2020-06-25T15:59:00.527Z| vmx| I125: Vix: [mainDispatch.c:4156]: VMAutomationReportPowerStateChange: Reporting power state change (opcode=2, err=0).
2020-06-25T15:59:00.528Z| vmx| I125: TOOLS Received tools.set.versiontype rpc call, version = 10304, type = 1
2020-06-25T15:59:00.528Z| vmx| I125: Tools_SetVersionAndType did nothing; new tools version (10304) and type (1) match old Tools version and type
2020-06-25T15:59:12.442Z| vmx| I125: VigorTransportProcessClientPayload: opID=fe05de9-2a-30ef seq=65225: Receiving GuestOps.CreateTemporaryDirectory request.
2020-06-25T15:59:12.674Z| vcpu-2| I125: VigorTransport_ServerSendResponse opID=fe05de9-2a-30ef seq=65225: Completed GuestOps request with messages.
2020-06-25T15:59:12.712Z| vmx| I125: VigorTransportProcessClientPayload: opID=53357423-74-30f5 seq=65236: Receiving GuestOps.CreateTemporaryFile request.
2020-06-25T15:59:12.720Z| vcpu-1| I125: VigorTransport_ServerSendResponse opID=53357423-74-30f5 seq=65236: Completed GuestOps request with messages.
2020-06-25T15:59:30.188Z| vmx| I125: GuestRpc: Got RPCI vsocket connection 526, assigned to channel 1.
2020-06-25T15:59:31.204Z| vmx| I125: GuestRpc: Got error for channel 1 connection 527: Remote disconnected
2020-06-25T15:59:31.204Z| vmx| I125: GuestRpc: Closing channel 1 connection 527
That path is defined in the environment variable $env:Temp
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, I'm able to create TEMP folder in C:\Windows folder.
Does logs from vmware.log help? or pls lmk if you need any other info?
Are you actually getting back C:\Windows when you display $env:Temp?
That should be a path under C:\Users\...
The log seems to say that the temp directory was created.
Which is strange, since the verbose message seems to indicate the creation of the temp folder failed.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You're right in powershell, $env:Temp is printing as C:\Users\QAD3DF_1.XRA\AppdData\Local\Temp
But in environment variables I see C:\Windows\Temp location, here is the screenshot
Validated that Temp folder exists in the $env:Temp location.
Ok, so the temp folder is created.
Next step is to use the KeepFiles switch.
That way the temporary folder and files will not be removed and we can check if they exist and what is in there
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I ran the Invoke-VMScriptPlus with KeepFiles switch. Here is the output:
In the Guest OS, I see these 2 files created in TEMP folder:
So it is in fact the temporary folder that doesn't get created.
I'll have to try and find out what the reason for that could be.
Especially strange since you stated it used to work before.
A wild guess, did you already try completely uninstalling/installing the VMware Tools inside the Guest OS?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, I did try to uninstall and install VMWare Tools on 6/23 before I posted the question here yesterday.
I will try again and let you know.
After uninstalling and reinstalling VMWare Tools, still getting the same error:
PS /Users/sgaikwad> $Command_text="dir C:\users\"
PS /Users/sgaikwad> Invoke-VMScript -VM $TARGET_VM -ScriptText $Command_text -GuestUser $vm_user -GuestPassword $vm_pass
Invoke-VMScript: 6/25/2020 5:39:05 PM Invoke-VMScript A general system error occurred: vix error codes = (1, 0).
Is this the only VM where you seeing this issue?
What Guest OS is running on there?
Fully patched?
Which VMware Tools version/build?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am working only with 2 VMs - one of them is working fine.
Guest OS: Windows 10 version 1903 (OS Build 18362.900)
VMWare Tools version: 10304 (10.2.0)
Btw, in my automation scripts - I revert to snapshots, run the test on app. By any chance does frequent snapshot reversal causes this issue? Snapshot is always 10-15 days old (have learnt in a hard way that if the snapshot is older than 1 month, user is unable to login and domain trust issues occur)