Please feel free to provide feedback or file bugs here.

Disable-ScheduledTask -TaskName will fail with tasks including spaces in name.

Steps to reproduce
------------------
Disable-ScheduledTask -TaskName "Data Integrity Scan for Crash Recovery"
Disable-ScheduledTask : The system cannot find the file specified.
At line:1 char:1
+ Disable-ScheduledTask "Data Integrity Scan for Crash Recovery"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [
Disable-ScheduledTask], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070002,Disable-ScheduledTask

Expected behavior
-----------------
This should disable the scheduled task and not crash.

You can workaround this by searching for the task object and disabling that way:

$Name = "Data Integrity Scan for Crash Recovery"
Get-ScheduledTask | where-object {($_.TaskName -eq $Name)} | Disable-ScheduledTask

Actual behavior
---------------
Crashes with the following exception:
Disable-ScheduledTask : The system cannot find the file specified.
At line:1 char:1
+ Disable-ScheduledTask "Data Integrity Scan for Crash Recovery"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [
Disable-ScheduledTask], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070002,Disable-ScheduledTask

Environment data
----------------
Name Value
---- -----
PSVersion 5.1.15063.296
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.296
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

3 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)

    We’ll send you updates on this idea

    Robert Pufky shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base