Empty Coder
Empty Coder

Reputation: 589

Delete task from task scheduler based on userid powershell

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

Upvotes: 0

Views: 248

Answers (1)

TomG
TomG

Reputation: 187

Try this (without -whatif):

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

Enjoy tom

Upvotes: 1

Related Questions