VMware Cloud Community
spradeepv
Contributor
Contributor

dir-cli failed, error= Could not connect to the local service VMware AFD. Verify VMware AFD is running. 1021

I am trying to create a vcenter user by using the dir-cli command and Invoke-Script module. The command works in some vCenters and in some of the vCenters it gives the following error:

dir-cli failed, error= Could not connect to the local service VMware AFD.                                                                              
Verify VMware AFD is running. 1021

The same dir-cli command works when executed in the vCenter by doing an ssh. It fails when invoked through a powershell script.
Any suggestions on resolving the issue.
Tags (1)
0 Kudos
7 Replies
Lalegre
Virtuoso
Virtuoso

How exactly are you running those command using PowerShell?

Could you show us the script itself and the execution of it?

0 Kudos
spradeepv
Contributor
Contributor

PFA script to create a user in vCenter.

0 Kudos
Lalegre
Virtuoso
Virtuoso

What if you try to run the InvokeVMScript portion of code manually without getting the credentials, does it work?

Also i can see on the code on the $cmd that you are using ' and " between $createscript and i guess there is a misstypo as one closes before the other one open (Maybe i am wrong)

0 Kudos
scott28tt
VMware Employee
VMware Employee

Moderator: Thread moved to the PowerCLI area.


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
0 Kudos
spradeepv
Contributor
Contributor

The same script works with other vCenters. I am facing this issue in one vCenter only.

0 Kudos
Lalegre
Virtuoso
Virtuoso

Oh good to know then, let's focus in the error then.

What is the status of the vmafdd service inside vCenter Server? Or inside the Platform Services Controller if you have an External Topology.

Maybe that is your issue thinking out loud. You are running the script inside the vCenter Server VM but it does not have that service because you have an external topology. If this is not the case please check the status of the serivces mentioned above.

0 Kudos
spradeepv
Contributor
Contributor

The service is running. Anything else to check?

0 Kudos