Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Register-ScheduledTask & New-TaskTrigger

$
0
0

I'm currently attempting to set up a scheduled task to delete it is self immediately, if it's not scheduled to run again. I should be able to do this with the -Settings parameter, I must not understand how the CImInstance works for setting it. Using the following command, I was able to figure out the setting I am looking for is DeleteExpiredTaskAfter:

Get-ScheduledTask -TaskName 'Test'|select-ExpandProperty Settings

The value of DeleteExpiredTaskAfter is set to PT0S. So in my script, I add -Settings DeleteExpiredTaskAfter "PT0S" to it, but it does not recognize the setting. I've never dealt with commands that require a CIM instance, so what am I doing wrong?

Also, for me to have the DeleteExpiredTaskAfter setting, I know I need to give my task trigger an expiration date. Replacing the Settings Parameter, with Triggers, I found the EndBoundary setting. How do I incorporate that into the trigger?


Viewing all articles
Browse latest Browse all 6937

Trending Articles