API Reference
Command
Set-CxScheduledTask
Creates, updates, enables, disables, removes, or starts a Scheduled Task.
Examples
Example 1
Set-CxScheduledTask -Path "\TestimoX\Collector" -Enable
Example 2
Set-CxScheduledTask -Path "\TestimoX\Collector" -RunNow
Example 3
Set-CxScheduledTask -Path "\TestimoX\Collector" -Command "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -Arguments "-File C:\\Scripts\\Collect.ps1" -TriggerKind AtStartup -RunElevated
Example 4
# Update principal to SYSTEM
Set-CxScheduledTask -Path "\Ops\Rotate" -RunAsUser 'SYSTEM' -RunElevated
Example 5
# Update principal to gMSA (auto ServiceAccount)
Set-CxScheduledTask -Path "\Ops\Sync" -RunAsUser 'CONTOSO\\svc-sync$'
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.
Syntax
Set-CxScheduledTask -Path <string> [-Arguments <string>] [-Command <string>] [-ComputerName <string>] [-Credential <PSCredential>] [-Description <string>] [-IncludeLolBins] [-Interval <TimeSpan>] [-LogonType <string>] [-RunAsUser <string>] [-RunElevated] [-StartBoundary <DateTime>] [-Suspicious] [-TriggerKind <Once|Daily|AtStartup|AtLogon>] [-WorkingDirectory <string>] [<CommonParameters>]#Parameter set:
By Arguments + CommandParameters
- Path string
- Full task path (e.g., \MyTasks\Example).
- Arguments string
- Optional arguments.
- Command string
- Executable to run.
- ComputerName string
- Target computer (omit or '.' for local).
- Credential PSCredential
- Credential for remote connections.
- Description string
- Optional description.
- IncludeLolBins SwitchParameter
- When -Suspicious is used, include LOLBIN heuristics in scoring.
- Interval TimeSpan
- Repeat interval for Daily triggers.
- LogonType string
- Optional logon type hint (Password, S4U, ServiceAccount).
- RunAsUser string
- User to run as (e.g., SYSTEM, NT AUTHORITY\SYSTEM, DOMAIN\User, or gMSA DOMAIN\name$).
- RunElevated SwitchParameter
- Run with highest privileges.
- StartBoundary DateTime
- Start time for Once/Daily triggers.
- Suspicious SwitchParameter
- When set (Update set), returns the updated task enriched with suspicion fields.
- TriggerKind TriggerKind
- Trigger kind (Once, Daily, AtStartup, AtLogon). Optional. Possible values: Once, Daily, AtStartup, AtLogon
- Possible values:
Once,Daily,AtStartup,AtLogon - WorkingDirectory string
- Optional working directory.
Outputs
ComputerX.ScheduledTasks.ScheduledTaskInfo, System.Boolean
Set-CxScheduledTask -Path <string> -Enable [-ComputerName <string>] [-Credential <PSCredential>] [<CommonParameters>]#Parameter set:
By EnableParameters
- Path string
- Full task path (e.g., \MyTasks\Example).
- Enable SwitchParameter
- Enable the task.
- ComputerName string
- Target computer (omit or '.' for local).
- Credential PSCredential
- Credential for remote connections.
Outputs
ComputerX.ScheduledTasks.ScheduledTaskInfo, System.Boolean
Set-CxScheduledTask -Path <string> -Disable [-ComputerName <string>] [-Credential <PSCredential>] [<CommonParameters>]#Parameter set:
By DisableParameters
- Path string
- Full task path (e.g., \MyTasks\Example).
- Disable SwitchParameter
- Disable the task.
- ComputerName string
- Target computer (omit or '.' for local).
- Credential PSCredential
- Credential for remote connections.
Outputs
ComputerX.ScheduledTasks.ScheduledTaskInfo, System.Boolean
Set-CxScheduledTask -Path <string> -Remove [-ComputerName <string>] [-Credential <PSCredential>] [<CommonParameters>]#Parameter set:
By RemoveParameters
- Path string
- Full task path (e.g., \MyTasks\Example).
- Remove SwitchParameter
- Remove the task.
- ComputerName string
- Target computer (omit or '.' for local).
- Credential PSCredential
- Credential for remote connections.
Outputs
ComputerX.ScheduledTasks.ScheduledTaskInfo, System.Boolean
Set-CxScheduledTask -Path <string> -RunNow [-ComputerName <string>] [-Credential <PSCredential>] [<CommonParameters>]#Parameter set:
By RunNowParameters
- Path string
- Full task path (e.g., \MyTasks\Example).
- RunNow SwitchParameter
- Start the task now.
- ComputerName string
- Target computer (omit or '.' for local).
- Credential PSCredential
- Credential for remote connections.
Outputs
ComputerX.ScheduledTasks.ScheduledTaskInfo, System.Boolean