Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Find all Scheduled Tasks and Disable them using Powershell+CMD

$
0
0
Hey guys,

I am new to PS and I am giving myself a headache trying to figure out how to do this.

I want to:
- Query list of sched tasks (SCHTASKS /QUERY /FO CSV) or similar
- Use a pattern to put all of the task names into a list (this is what I'm stuck with)
- Disable/Enable all tasks (some kind of loop with: SCHTASKS /CHANGE /TN $tasknames /DISABLE)

I managed to match the task name with this regex: '\"\\([^\"]+)\"'
But it only matches the first task name and I'm not sure exactly what to use to loop this through each line (preferably only once)

Anyone know how to do this? It's mainly the matching + putting names into a list variable that is difficult for me.

Viewing all articles
Browse latest Browse all 2562

Trending Articles