0

What I am trying to do is to capture everything in a powershell script and save it in a text file. I would like it as if I manually selected all, copied, then pasted in a text file.

I have explored Start-Transcript, but it does not show the Read-Host's. The only solutions I can think of is to Write-Host right after every time I use Read-Host. Is there any other way?

zett42
  • 25,437
  • 3
  • 35
  • 72
Pa3k.m
  • 994
  • 2
  • 7
  • 22
  • Just an idea: define a function named `Read-Host` in your code that calls the real `Read-Host` and logs its output. Generate the source of a wrapper function like this: `[System.Management.Automation.ProxyCommand]::Create(( Get-Command Read-Host ))` and modify it to log the output of `$steppablePipeline.Process($_)` – zett42 May 09 '22 at 16:56
  • Does this answer your question? [Is there a way to set a variable up to place output to stdout or null?](https://stackoverflow.com/questions/58610934/is-there-a-way-to-set-a-variable-up-to-place-output-to-stdout-or-null) – codewario May 09 '22 at 18:42

1 Answers1

0

This should work

$application_name >> textfile.text

Here is an example

$ ifconfig >> textfile.text

'>>" means where the output should be saved

takudzw_M
  • 186
  • 1
  • 5