Forum Discussion
RedModSK
Jun 08, 2023Copper Contributor
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...
- Jun 08, 2023
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
LainRobertson
Jun 08, 2023Silver Contributor
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
RedModSK
Jun 08, 2023Copper Contributor
LainRobertson
Thats it, thank you mate!
I am surprised and a bit ashamed, that i did not see it when i was going through the properties.
Cheers ![]()