TestimoX

API Reference

Command

New-CxScheduledTask

Namespace ComputerX.PowerShell
Outputs
ComputerX.ScheduledTasks.ScheduledTaskInfo System.Boolean

Creates a new Scheduled Task with a single Exec action.

Examples

Authored help example

Example 1


New-CxScheduledTask -Path "\TestimoX\Collector" -Command "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -Arguments "-File C:\\Scripts\\Collect.ps1" -TriggerKind AtStartup -RunElevated
        

Example 2


# SYSTEM principal
            New-CxScheduledTask -Path "\Ops\Rotate" -Command "C:\\Tools\\rotate.exe" -TriggerKind Daily -StartBoundary '02:00' -RunAsUser 'SYSTEM'
        

Example 3


# gMSA principal (auto ServiceAccount logon)
            New-CxScheduledTask -Path "\Ops\Sync" -Command "C:\\Tools\\sync.exe" -TriggerKind AtStartup -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

New-CxScheduledTask -Path <string> -Command <string> [-Arguments <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>]
#

Parameters

Path string requiredposition: 0pipeline: false
Full task path (e.g., \MyTasks\Example).
Command string requiredposition: 1pipeline: false
Executable to run.
Arguments string optionalposition: 2pipeline: false
Optional arguments.
ComputerName string optionalposition: namedpipeline: false
Target computer (omit or '.' for local).
Credential PSCredential optionalposition: namedpipeline: false
Credential for remote connections.
Description string optionalposition: namedpipeline: false
Optional description.
IncludeLolBins SwitchParameter optionalposition: namedpipeline: false
When -Suspicious is used, include LOLBIN heuristics (mshta/wscript/pwsh/etc.).
Interval TimeSpan optionalposition: namedpipeline: false
Repeat interval for Daily triggers.
LogonType string optionalposition: namedpipeline: false
Optional logon type hint (Password, S4U, ServiceAccount).
RunAsUser string optionalposition: namedpipeline: false
User to run as (e.g., SYSTEM, NT AUTHORITY\SYSTEM, DOMAIN\User, or gMSA DOMAIN\name$).
RunElevated SwitchParameter optionalposition: namedpipeline: false
Run with highest privileges.
StartBoundary DateTime optionalposition: namedpipeline: false
Start time for Once/Daily triggers.
Suspicious SwitchParameter optionalposition: namedpipeline: false
When set, returns the created task enriched with suspicion fields.
TriggerKind TriggerKind optionalposition: namedpipeline: falsevalues: 4
Trigger kind (Once, Daily, AtStartup, AtLogon). Optional. Possible values: Once, Daily, AtStartup, AtLogon
Possible values: Once, Daily, AtStartup, AtLogon
WorkingDirectory string optionalposition: namedpipeline: false
Optional working directory.

Outputs

ComputerX.ScheduledTasks.ScheduledTaskInfo, System.Boolean