1

I call a PowerShell Script trough c#.net. After calling the script nothing happens, and I don’t get any error to track the issues. I need the output of the complete script execution.

Is it possible to write the PowerShell log/output somewhere?

1 Answer 1

2

Assuming the Start-Transcript method will not work because we are not in the PS console session, this leaves us with a few alternatives in Powershell v 2.0.

One method I like is Write-Host combined with Add-Content, so I can both see and retain certain results. If you are in the pipeline you can use the Out-File -Append

Write-Host $Data;Add-Content $Output $Data;

Out-File -Append -FilePath $Output

Tee-Object cannot append from Powershell v2, so I would avoid it unless you cannot.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.