API Reference
Command
New-CxScheduledTask
Creates a new Scheduled Task with a single Exec action.
Examples
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
- Full task path (e.g., \MyTasks\Example).
- Command string
- Executable to run.
- Arguments string
- Optional arguments.
- 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 (mshta/wscript/pwsh/etc.).
- 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, returns the created 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