Forum Discussion

RedModSK's avatar
RedModSK
Copper Contributor
Jun 08, 2023
Solved

Check Disabled state after Disable-ScheduledTask status on Running Task

Hello to all, i seek your wisdom! I am trying to automate the following steps performed manually: - Disable a running scheduled task, but keeping it running. - Do actions that stop the task proces...
  • LainRobertson's avatar
    LainRobertson
    Jun 08, 2023

    RedModSK 

     

    Hi,

     

    Sorry, try this instead, which checks the Settings.Enabled property:

     

    Get-ScheduledTask -TaskName "SystemSoundsService" |
        ForEach-Object {
            [PSCustomObject] @{
                Task = "$($_.TaskPath)$($_.TaskName)";
                State = $_.State;
                Enabled = $_.Settings.Enabled;
            }
    }

     

    The principle is the same as for Triggers, it's just that the Settings.Enabled describes the job as a whole rather than Triggers.Enabled that returns the status of each trigger in the Triggers array.

     

    Cheers,

    Lain

Resources