VMware Cloud Community
joshcr90
Contributor
Contributor
Jump to solution

Invoke-VMScript GuestUser error

Hello,

I have a Powershell Script (Powershell 6.1) which contains the following line

Invoke-VMScript -VM $vmName -GU testuser -GP testpass -ScriptText $script -ScriptType bash

The intention of the script is to run linux commands on a linux server. The issue that I'm experiencing with this line is that when I run this script, I get the following error:

Invoke-VMScript : x/xx/xx 0:00:00 PM    Invoke-VMScript         Failed to authenticate with the guest operating system using the supplied credentials.                                 At /opt/testscript.ps1:21 char:15                                                                                                                                     + ...   $result = Invoke-VMScript -VM $vmName -GU testuser -GP testpass -ScriptTex ...                                                                                                        +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                            + CategoryInfo          : NotSpecified: (:) [Invoke-VMScript], InvalidGuestLogin                                                                                                       + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_RunScriptInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript 

The password specified is correct. The user is part of the domain (LDAP authentication, not Active Directory). I tried creating a local user in the target server with the same password (to discard special characters issues), and it worked. I'm thinking this could be related to GuestUser only being able to authenticate against local users. Could you please help me with some guidance to understand what is going on in my scenario?

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

That is most probably because the authentication is done from the vmtoolsd daemon.
Can you verify if KB78251 might be applicable?


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Did you already check /var/log/secure and /var/log/messages on the target VM for any LDAP related authentication issues?


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

0 Kudos
joshcr90
Contributor
Contributor
Jump to solution

I see the following error at /var/log/secure:


xxxx testserver VGAuth[1012]: pam_unix(vmtoolsd:auth): authentication failure; logname= uid=0 euid=0 tty= ruser= rhost=  user=testuser

xxxx testserver unix_chkpwd[11346]: check pass; user unknown

xxxx testserver unix_chkpwd[11346]: password check failed for user (testuser)

xxxx testserver VGAuth[1012]: PAM 1 more authentication failure; logname= uid=0 euid=0 tty= ruser= rhost=  user=testuser

Jun 30 19:52:36 testserver VGAuth[1012]: vmtoolsd: Username and password mismatch for 'testuser'.

I tried to login through regular SSH connection with that user and it does work, it's only through Powercli where it fails.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That is most probably because the authentication is done from the vmtoolsd daemon.
Can you verify if KB78251 might be applicable?


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

0 Kudos
joshcr90
Contributor
Contributor
Jump to solution

LucD​, Thank you, that fixed it.

0 Kudos