SSAS Cube Process Manually works but MDX query doesnt work
If you want to make sure the code you are running is exactly the code run when you process manually you should click the script button in SSMS and use that XMLA script. If you execute a series of steps you should script each step.



This will generate the scripts as XML so you can execute in SSMS and that will 100% do the same as clicking the OK button on the dialog.

If that works you should get output like this (empty result)

&lt;return xmlns="urn:schemas-microsoft-com:xml-analysis"&gt;
  &lt;results xmlns="http://schemas.microsoft.com/analysisservices/2003/xmla-multipleresults"&gt;
    &lt;root xmlns="urn:schemas-microsoft-com:xml-analysis:empty" /&gt;
  &lt;/results&gt;
&lt;/return&gt;


If that doesn't work you should get a response indicating an error like this

&lt;return xmlns="urn:schemas-microsoft-com:xml-analysis"&gt;
  &lt;results xmlns="http://schemas.microsoft.com/analysisservices/2003/xmla-multipleresults"&gt;
    &lt;root xmlns="urn:schemas-microsoft-com:xml-analysis:empty"&gt;
      &lt;Exception xmlns="urn:schemas-microsoft-com:xml-analysis:exception" /&gt;
      &lt;Messages xmlns="urn:schemas-microsoft-com:xml-analysis:exception"&gt;
        &lt;Error ErrorCode="3239313412" Description="Errors in the metadata manager. Either the database with the ID of 'testA' does not exist in the server with the ID of 'MES-TVG-80-U15', or the user does not have permissions to access the object." Source="Microsoft SQL Server 2016 Analysis Services" HelpFile="" /&gt;
      &lt;/Messages&gt;
    &lt;/root&gt;
  &lt;/results&gt;
&lt;/return&gt;


Once you have the correct script you can paste that in your agent job. If that doesn't work you should be looking for either errors in your agent job, or checking to see if the agent job is connecting to the right server, processing the right database, using the correct credentials etc.

Side note: If you do have multiple steps, and as such multiple XMLA scripts you can combine them using a  tag like I show here: how to delete multiple ssas database using xmla script