windows-powershell-docs icon indicating copy to clipboard operation
windows-powershell-docs copied to clipboard

New-ScheduledTask Example 2 Incorrect

Open PaulDash opened this issue 1 year ago • 1 comments

Prerequisites

  • [X] Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
  • [X] Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Typo in Get-Foo cmdlet" instead of "Typo."
  • [X] Verify Version: If there is a mismatch between documentation and the behavior on your system, ensure that the version you are using is the same as the documentation. Check this box if they match or the issue you are reporting is not version specific.

Links

https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtask?view=winserver2012-ps#examples

Summary

Example 2 states that two scripts will be run. The scripts will open in an editor.

Details

The example description states that: This example creates and registers a scheduled task that runs two PowerShell scripts daily at 09:15 AM.

Meanwhile, using New-ScheduledTaskAction -Execute 'foo.ps1' will only launch the editor associated with .ps1 files on a given system and will not execute the script.

Suggested Fix

The example should show how to execute pwsh.exe (or powershell.exe for older versions) along with arguments that point to executing the scripts. The example can then be expanded to show how to save the output generated by those scripts.

PaulDash avatar Nov 08 '24 12:11 PaulDash

This issue is in the wrong repository. The MicrosoftDocs/PowerShell-Docs repository contains the content for the base PowerShell product. The documentation for the Windows management modules is MicrosoftDocs/windows-powershell-docs.

I have transferred this issue to the correct repository.

sdwheeler avatar Nov 08 '24 20:11 sdwheeler