I'm trying to create a simple scheduled task using powershell v1.0, and as I look through the Task Scheduler object on MSDN http://msdn.microsoft.com/en-us/library/windows/desktop/aa383607%28v=vs.85%29.aspx I'm not sure I really understand what I'm doing...
So far in my code I have the following:
Function createFirefoxTask() {
$schedule = new-object -com Schedule.Service
$schedule.connect()
$tasks = $schedule.getfolder("\").gettasks(0)
$firefoxTaskExist=$false
# Check if the firefox schedule task exists
foreach ($task in ($tasks | select Name)) {
if($task.name.equals("FirefoxMaint")) {
$firefoxTaskExist=$true
break
}
}
# Create the scheduled task if it does not exist
if($firefoxTaskExist -eq $false) {
write-output "Creating firefox task..."
$firefoxTask=$schedule.NewTask(0)
$firefoxTask | get-member
}
}
But the members assigned to the $firefoxTask
don't seem to make sense to me. For example, how do I do something as simple as naming my new task?
Here is the output I received...
TypeName: System.__ComObject#{f5bc8fc5-536d-4f77-b852-fbc1356fdeb6}
Name MemberType Definition
---- ---------- ----------
Actions Property IActionCollection Actions () {get} {set}
Data Property string Data () {get} {set}
Principal Property IPrincipal Principal () {get} {set}
RegistrationInfo Property IRegistrationInfo RegistrationInfo () {get} {set}
Settings Property ITaskSettings Settings () {get} {set}
Triggers Property ITriggerCollection Triggers () {get} {set}
XmlText Property string XmlText () {get} {set}
None of the above members seem to make sense for what I'm trying to do if I drill further into them.