How to get stdout from Start-ADTProcessAsUser

I’m not sure if the ‘Tips & Tricks’ thread on this cmdlet is relevant for this issue, but I’m basically trying to get STDOut from this PSADT cmdlet.

I’ve tried a few different things, but basically I want to store the output from a command to a variable, then make an if/else statement based on the output of that variable.

$SqlLocalDBStatus = Start-ADTProcessAsUser -FilePath “sqllocaldb” -ArgumentList “i” -PassThru

Is essentially what I’m trying to do, I’d like to see the output of the sqllocaldb i command. The command runs, but I don’t get the STDOut in the variable.

I’ve tried with and without PassThru, with and without Wait, with and without NoRedirectOutput and with and without OutputDirectory as well as combinations of all of the above.

I’m also a little confused, the PassThru param in the documentation states

If NoWait is not specified, returns an object with ExitCode, STDOut and STDErr output from the process. If NoWait is specified, returns an object with Id, Handle and ProcessName.

But there is not a NoWait param - there is Wait and WaitOption - so I’m not sure if I’m just flat out doing something wrong, if the documentation is outdated, if there’s a bug…

I’ll try with v3, but I’ve never tried to do this before with PSADT.

I’ll level with you, that entire function requires some significant retooling which we’re aiming to have done for 4.1.0. Currently there’s no way to get stdout or stderr from it, but it’s on the top of my list of things to get onto.

1 Like

Ah, OK well at least I’m not crazy.

Does this work in v3? I was going to try but if you know it doesn’t work there I won’t put the effort in.

Thanks!

It doesn’t, I’m afraid.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.