Management Agent - Management Agent is running, but error like below prevent discovery to run - CommandNotFoundException
Symptom
Even though agent is running, but error like below prevent discovery to run. Error in Program Files\CyberArk\Management Agent\logs\client_log.txt:
{"level":"info","time":"xxx","msg":"command stderr buffer","appName":"management-agent","jobID":"operation-task-xxx","buffer":"./bin/RunDiscoveryEngine.ps1 : The term './bin/RunDiscoveryEngine.ps1' 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.
At line:1 char:1
+ ./bin/RunDiscoveryEngine.ps1 -scanId xxx ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (./bin/RunDiscoveryEngine.ps1:String) [], CommandNo
tFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Environment
Privilege Cloud Connector Management
PCloud Discovery(new), Connector Management Agent
Cause
When an operation runs on connector management, it first downloads all the needed packages, moves them to the unique workspace of the operation, unzips them, and does some operating command on them. If it's a PS script, for example, an operation can run it.
In order to run it, the operation manifest needs to know the path which the file is unzipped to. The file path is relative to the workspace, and thus, it resides in the same path relative to the operation that runs for all tenants.
Some possible issues:
1. Permission issue - the operation process cannot get to the file, and thus an error of type "object not found" is thrown
2. AntiVirus issue - The AntiVirus collects the unzipped .ps1 files and quarantines them.
Resolution
- Stop anti-virus program.
- Check to make sure NT Service\Idira Management Agent has full permission on the folder. You can use this command to see details: Get-Acl "C:\Program Files\CyberArk\Management Agent" | Format-List
- Make sure you can run PS script on the connector server:
Set-ExecutionPolicy -Scope P LocalMachine S -ExecutionPolicy RemoteSigned
Set-ExecutionPolicy -Scope currentuser -ExecutionPolicy ByPass