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.