Home > database >  Delete task from task scheduler based on userid powershell
Delete task from task scheduler based on userid powershell

Time:03-03

I need to find tasks which runs using SYSTEM and delete rest of the tasks running using any other account

enter image description here

I was trying to find the job first, then unregister, but not getting any filters to do that.

Get-ScheduledTask -TaskName "SPOC_Inventory"

Need help in this

CodePudding user response:

Try this (without -whatif):

PS C:\> Get-ScheduledTask SPOC_Inventory | ? {($_.Principal.UserId -ne "SYSTEM")}| Unregister-ScheduledTask -WhatIf

Enjoy tom

  • Related