locked
Syntax problem: "Set-ScheduledTask $_" RRS feed

  • Question

  • Hi everyone!

    Long story short: trying to use this PowerShell script I found online to force all scheduled tasks in Windows 10 (latest version in Oct 2017) to never wake up my device at night. 

    Get-ScheduledTask | ?{ $_.Settings.WakeToRun -eq $true -and $_.State -ne 'Disabled' } | %{ $_.Settings.WakeToRun = $false; Set-ScheduledTask $_ }

    But for some reason, (because of my version of PowerShell maybe) the last line of this code returns this error:

    Set-ScheduledTask : The parameter is incorrect.
    + ... d"} | % {$_.Settings.WakeToRun = $false; Set-ScheduledTask $_}
    +                                                                    ~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [Set-ScheduledTask], CimException
    + FullyQualifiedErrorId : HRESULT 0x80070057,Set-ScheduledTask


    At this point, I really need to make just this script work.

    What can I do to make this particular line of code to work properly?

    Thank you!

    Friday, October 13, 2017 10:54 AM

All replies

  • Sorry but we do not fix code found on the Internet.

    The code clearly has never worked.  You will have to write your own code.

    Apparently you have some issues with your system. Also the error does not match the code you posted.   


    \_(ツ)_/

    Friday, October 13, 2017 11:11 AM