3

I have a PowerShell script that produces output to the screen when running it from the PowerShell command line. When I run the PowerShell script as a Scheduled Task, where can I find the output?

Robin
  • 151
  • 1
  • 5

3 Answers3

2

You won't find your output anywhere from your scheduled task. I would suggest sending your scripts output to a text file, you can do so easily by piping your output to the out-file command, e.g.

get-mailbox |out-file c:\mailboxes.txt

Or output the whole of your files output using a standard DOS file redirect > file.txt

Sam Cogan
  • 38,736
  • 6
  • 78
  • 114
1

As far as I know, you won't find it anywhere.

You'll need to either open a text file and write the output there, or write a small batch file that redirects standard output to a text file.

For example, I use a batch file something like this:

powershell test.ps1 > output.txt
Anthony Lewis
  • 909
  • 7
  • 8
1

In a scheduled task just prefix the entire command with cmd /c

example: cmd /c powershell test.ps1 > output.txt