VMware Cloud Community
RobMerritt
Contributor
Contributor

Invoke-VMScript question , find if a successfull password reset has occured

 

I am trying to use PowerCLI to update passwords on our VMWare infra structure for all windows serversthe command I am using is:

 

Invoke-VMScript -VM $hostname -ScriptText "net user $UserName $PassWord" -GuestUser serveradmin -GuestPassword $DPWD -Verbose >> C:\temp\PasswordChange\$UserName-Success.txt

so just trying to change a local Windows user password with the windows cmd line command "net user $UserName $PassWord"

when doing this it works seemingly but I get :

 

ERBOSE: Performing the operation "Invoke-VMScript" on target "ICT-MWP-CSREG1".
WARNING: The version of VMware Tools on VM 'ICT-MWP-CSREG1' is out of date and may cause Invoke-VMScript to work improperly.
VERBOSE: Performing the operation "Invoke-VMScript" on target "ICT-MWP-CSREG1".
WARNING: The version of VMware Tools on VM 'ICT-MWP-CSREG1' is out of date and may cause Invoke-VMScript to work improperly.
VERBOSE: 8/15/2023 8:02:13 AM Invoke-VMScript Finished execution
Invoke-VMScript : 8/15/2023 8:02:14 AM Invoke-VMScript The operation is not allowed in the current state.
At C:\Users\admin.merrr1\scripts\powercliGetAllVMS.ps1:49 char:17
+ ... $output = Invoke-VMScript -VM $hostname -ScriptText "net user $User ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-VMScript], InvalidState
+ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_RunScriptInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript

 

 

is there a way to get rid of this seeminly erroneous error, I would like to be able to know if it failed on some servers (since some might not have that local user for instance)

Tags (1)
Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

That error looks more like the VMware Tools are not running.


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

Reply
0 Kudos
RobMerritt
Contributor
Contributor

I just checked on ict-mwp-csreg1 and tools are running , also just ran the script and changed ,y password but I still get that output.vmtools.PNGg , as well I just ran the script and changed my password.

Reply
0 Kudos
LucD
Leadership
Leadership

That error can have other reasons.

Sometimes the vmware.log shows some additional info.
You can also have a look in the vpxd log on the VCSA.

Some actions you might try:
- stop/start your PS/PowerCLI session
- unregister/register the VM that causes the error
- update the VMware Tools


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

Reply
0 Kudos