Freigeben über


ScheduledJobDefinition Class

Definition

This class contains all information needed to define a PowerShell job that can be scheduled to run through either stand-alone or through the Windows Task Scheduler.

[System.Serializable]
public sealed class ScheduledJobDefinition : IDisposable, System.Runtime.Serialization.ISerializable
[<System.Serializable>]
type ScheduledJobDefinition = class
    interface ISerializable
    interface IDisposable
Public NotInheritable Class ScheduledJobDefinition
Implements IDisposable, ISerializable
Inheritance
ScheduledJobDefinition
Attributes
Implements

Constructors

ScheduledJobDefinition(JobInvocationInfo, IEnumerable<ScheduledJobTrigger>, ScheduledJobOptions, PSCredential)

Constructor.

Properties

Command

Job command.

Credential

Credential.

Definition

Contains the script commands that define the job.

Enabled

Determines whether this scheduled job definition is enabled in Task Scheduler.

ExecutionHistoryLength

Returns the maximum number of job execution data allowed in the job store.

GlobalId

Global Id for scheduled job definition.

Id

Local instance Id for object instance.

InvocationInfo

Contains information needed to run the job such as script parameters, job definition, user credentials, etc.

JobTriggers

An array of trigger objects that specify a time/condition for when the job is run.

Name

Name of scheduled job definition.

Options

Specifies Task Scheduler options for the scheduled job.

PSExecutionArgs

Returns PowerShell command line arguments to run the scheduled job.

PSExecutionPath

Returns the PowerShell commond line execution path.

Methods

AddTriggers(IEnumerable<ScheduledJobTrigger>, Boolean)

Adds new ScheduledJobTriggers.

ClearExecutionHistory()

Clears all execution results in the job store.

Dispose()

Dispose.

GetObjectData(SerializationInfo, StreamingContext)

Serialization constructor.

GetTrigger(Int32)

Finds and returns a copy of the ScheduledJobTrigger corresponding to the passed in trigger Id.

GetTriggers(IEnumerable<Int32>, List<Int32>)

Returns a list of new ScheduledJobTrigger objects corresponding to the passed in trigger Ids. Also returns an array of trigger Ids that were not found in an out parameter.

LoadFromStore(String, String)

Creates a new ScheduledJobDefinition object from a file.

Register()

Registers this scheduled job definition object by doing the following: a) Writing this object to the scheduled job object store. b) Registering this job as a Windows Task Scheduler task. c) Adding this object to the local repository.

Remove(Boolean)

Removes this definition object: a) Removes from the Task Scheduler or fails if an instance is currently running. or stops any running instances if force is true. b) Removes from the scheduled job definition store. c) Removes from the local repository. d) Disposes this object.

RemoveTriggers(IEnumerable<Int32>, Boolean)

Removes triggers matching passed in trigger Ids.

Run()

Create a Job2 job, runs it and waits for it to complete. Job status and results are written to the job store.

RunAsTask()

Starts registered job defintion running from the Task Scheduler.

Save()

Saves this scheduled job definition object: a) Rewrites this object to the scheduled job object store. b) Updates the Windows Task Scheduler task.

SetEnabled(Boolean, Boolean)

Sets the enabled state of this object.

SetExecutionHistoryLength(Int32, Boolean)

Sets the execution history length property.

SetName(String, Boolean)

Sets the name of this scheduled job definition.

SetTriggers(IEnumerable<ScheduledJobTrigger>, Boolean)

Creates a new set of ScheduledJobTriggers for this object.

StartJob()

Starts the scheduled job immediately. A ScheduledJob object is returned that represents the running command, and this returned job is also added to the local job repository. Job results are not written to the job store.

StartJob(String)

Starts a scheduled job based on definition name and returns the running job object. Returned job is also added to the local job repository. Job results are not written to store.

UpdateJobInvocationInfo(JobInvocationInfo, Boolean)

Updates the JobInvocationInfo object.

UpdateOptions(ScheduledJobOptions, Boolean)

Updates scheduled job options.

UpdateTriggers(IEnumerable<ScheduledJobTrigger>, Boolean)

Updates triggers with provided trigger objects, matching passed in trigger Id with existing trigger Id.

Applies to