Thoughts from Dan Miser RSS 2.0
# Friday, April 27, 2012
I needed a way to get a list of specific scheduled tasks running on a server. The main problem is that the command-line tool, schtasks.exe, is horrid. There is no ability to filter data. You get all of the data, or you get none. This is the Powershell script that I eventually settled on after piecing together a bunch of StackOverflow and blog entries. The key is the convertfrom-csv cmdlet that turns the result into objects that can be queried on, instead of a list of strings.

It's my first time using Powershell, and I don't know quite what to think. While it helped me solve my objective, and is quite powerful and extensible, it just doesn't feel natural to me. I'm sure that would change over time if I decide to invest time and energy to grok it. If anyone knows of a less awkward LINQ syntax, please let me know because that would turn me around on Powershell in a heartbeat.


schtasks /query /v /fo:csv | convertfrom-csv | where {$_.'Task To Run' -like '*MyProcess.exe*' }
Friday, April 27, 2012 2:36:50 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -

Navigation
Archive
<December 2014>
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2014
Dan Miser
Sign In
Statistics
Total Posts: 388
This Year: 0
This Month: 0
This Week: 0
Comments: 630
Themes
Pick a theme:
All Content © 2014, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)