In my PowerShell script I'm calling a command that takes a file path as a parameter and writes its output to that file path.
For example, the command would look like this C:\mycommand.exe D:\test.csv, where D:\test.csv will be the new file created by the command.
And in Powershell, I'm calling that command like this $test = & "C:\mycommand.exe" D:\test.csv.
My intention is that instead of creating the D:\test.csv file, the csv output from the command would be captured by the $test variable and not create the csv file at all.
Instead, what I see happening is that the file is created and $test is empty.
Is there a variable that can act as a file stream that I can pass to the command that would capture the output of the command? Or a way to redirect to a variable without writing the file?