Execute-process Question

I have been using this toolkit for a while now and this is really handy to create a SCCM deployment packages. For the first time I’m facing a requirement very similar to below.

The standard output from a command-line has to be captured. where as -passthru
only allow to display\log only few lines. Example below

PS C:> Execute-Process -Path “$envSystem32Directory\cscript.exe” -Parameters “$envSystem32Directory\slmgr.vbs /dlv” -PassThru
[02-19-2020 01:46:29.764] [Initialization] [Execute-Process] :: [C:\WINDOWS\system32\cscript.exe] is a valid fully qualified path, continue.
[02-19-2020 01:46:29.784] [Initialization] [Execute-Process] :: Working Directory is [C:\WINDOWS\system32].
[02-19-2020 01:46:29.798] [Initialization] [Execute-Process] :: Executing [C:\WINDOWS\system32\cscript.exe C:\WINDOWS\sy
stem32\slmgr.vbs /dlv]…
[02-19-2020 01:46:33.109] [Initialization] [Execute-Process] :: Execution completed with exit code [0].

Microsoft ® Windows Script Host Version 5.8…

Actual standard output can be tested with the below command in cmd.
command: Cscript.exe slmgr.vbs /dlv.

Is there any thing that i could do. !? am I missing anything.!?
your thoughts and suggestions would be much helpfull.

Use a variable to capture the result:
$rc = Execute-Process -Path -Path “$envSystem32Directory\cscript.exe” -Parameters “/nologo $envSystem32Directory\slmgr.vbs /dlv” -PassThru

$rc.StdOut and $rc.StdErr will contain output from stdout and stderr streams
Also add /nologo to the arguments to suppress the “Microsoft ® Windows Script Host Version 5.8” lines

Wow Great!! that helps!!!