Forum Discussion
Check Disabled state after Disable-ScheduledTask status on Running Task
- 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
i was poking around the system where could i see some additional info and i found this, when running schtasks /query:
PS C:\Windows\System32> schtasks /query /TN "\RtkAudUService64_BG" /XML
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2010-07-30T20:43:10</Date>
<Author>Realtek</Author>
<URI>\RtkAudUService64_BG</URI>
</RegistrationInfo>
<Principals>
<Principal id="Author">
<GroupId>S-1-5-32-545</GroupId>
</Principal>
</Principals>
<Settings>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<Enabled>false</Enabled>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<MultipleInstancesPolicy>Parallel</MultipleInstancesPolicy>
<IdleSettings>
<Duration>PT10M</Duration>
<WaitTimeout>PT1H</WaitTimeout>
<StopOnIdleEnd>false</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
</Settings>
<Triggers>
<LogonTrigger>
<Delay>PT30S</Delay>
</LogonTrigger>
</Triggers>
<Actions Context="Author">
<Exec>
<Command>""C:\WINDOWS\System32\DriverStore\FileRepository\realtekservice.inf_amd64_ed3f04e1261e4822\RtkAudUService64.exe""</Command>
<Arguments>-background</Arguments>
</Exec>
</Actions>
</Task>
The <Enabled>false</Enabled> line in Settings, is visible only when the task is disabled.
I would rather however use the PowerShell commandlets, to get the values.
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
- RedModSKJun 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