Need Help in getting the log file for the script running in Task Scheduler

Log file not being generated while running a PowerShell script via Windows Task Scheduler.

Script as below:

stop-service "3900"

start-sleep -s 60

stop-service "3200"

Restart-computer Q234X  -Force

Send -MailMessage  -From  -To -subject  test  -attach "c:\Temp\test .log"  -smtpserver ""

In windows task scheduler I have entered the following information:

In Action tab:


Arguments tab:

-file “c:\scripts\New_test.ps1”*>“C:\Temp\New_test.log”


Can anyone help me in getting the log file while running the script via Task Scheduler?

What output would you expect to be redirected to your “New_test.log”? The cmdlets you use usually do not produce any output by default. Try you add a

Get-Date | Out-File -FilePath C:\Temp\New_test.log
to your script to test.

If you want a proper transcript, you can use the Start-Transcript and Stop-Transcript cmdlets. :slight_smile: