Environment variables on a Windows Runner


We’re running builds on Gitlab SAAS, and looking to run builds using the Windows runner. I have it set up and running (including installing maven), but when I run:


Where $MAVEN_CLI_OPTS and $MAVEN_SETTINGS_XML are variables set further up in the script. The response I get is that the mvn command format is wrong.
Does anyone have any thoughts on how I might see what has actually been run by that command?

I have got the command running by using:

Invoke-Expression "mvn $MAVEN_CLI_OPTS clean install -s $MAVEN_SETTINGS_XML"

But then the return code from the command doesn’t then get returned from the script, so when the maven command fails, the build just carries on. If there are any thoughts on how to ge the exit code returned, that could work too?

Thanks in advance for any thoughts/advice.