screen -dmS workspace; screen -S workspace -X stuff $'ps aux > output-x\n'
I first create a detached session with the -d switch, I called my session workspace. I then send my command to the same session with -X stuff, I am using $'', but you could also use double quotes, but have to do a control M instead of a \n, which I don't like so I normally use the method I described above.
After this piece of code runs, you will find the output-x with the list of processes, and also if you do a:
you will see the session has been detached.
Since you said you are going to be running a script. You might want to have your script search for a detached session (I am using workspace), and if it exists send commands to that pre-existing session, instead of making a new session every time "screen -dmS sessionName" is ran, example is below:
if ! ( screen -ls | grep workspace > /dev/null); then
screen -dmS workspace;
screen -S workspace -X stuff $'ps aux > output-x\n'