Powershell script to fetch task name from notepad and find the status of it in windows task scheduler -


i need powershell script tasks listed out in text file needs read , status of tasks needs fetched windows task scheduler , output in csv file.

i able read contents using get-content cmdlet.but get-scheduledtask throwing error not recognized valid cmdlet.

kindly me new powershell.

get-scheduledtask tasks | get-scheduledtaskinfo | select-object taskname, lasttaskresult | export-csv -notypeinformation -path d:\first\one.csv

i have txt file named tasks contain list of tasks iterated , listed out csv file

this 1 works me:

$tasks = get-content -path "c:\users\administrator\desktop\tasks.txt" get-scheduledtask -taskname $tasks | get-scheduledtaskinfo | select-object taskname, lasttaskresult | export-csv c:\users\administrator\desktop\tasks.csv -notypeinformation 

txt file in following format:

task 1 task 2 task 3 

i've tried in ps 4 on windows 8.1, don't have cmdlet in previous versions of windows (like windows 7 / windows server 2008 r2).

for previous versions, can use great module. should extract entire folder in modules folder, e,g. c:\windows\system32\windowspowershell\v1.0\modules , can use get-scheduledtask module this:

import-module taskscheduler get-content -path "c:\users\administrator\desktop\tasks.txt" | foreach-object { get-scheduledtask -name $_ | select-object name,lastruntime } | export-csv c:\users\administrator\desktop\tasks.csv -notypeinformation 

other solution try play around schtasks.exe or schedule.service com object think module taskscheduler easier you.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -