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 process.
Do additional actions.
Enable scheduled task and run it.
I can do all the steps in PowerShell, but the issue i have is that when i use:
Disable-ScheduledTask -TaskName ‘TaskName’ -TaskPath '\TaskPath'
while the task remains running, i am not able to get the Disabled state with:
Get-ScheduledTask -TaskName ‘TaskName’ -TaskPath '\TaskPath'
In the taskschd.msc ui i can see the option to enable the task, so i see hat is is disabled
But i need to confirm the Disabled state from PowerShell.
I am not able to find anything in task cim properties either.
I hope one of you knows the solution to my dilema.
… successfully ran wihtout error - the task is disabled.
BTW: When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Hello Olaf,
thank you for your reply. Yes you are right, no error is good enough to me, but i need the script to be able to check the status for other tasks as well. Otherwise an sql instance would auto-start and job queue would populate again. Also i need to write logs.
However it is solved now. I posted also on MS tech community and i got pointed to the now obvious and convenient settings.enabled boolean property.