Run Logon Triggered Tasks on Windows Devices Using Commands

Using the Commands feature, IT admins can deploy scripts and commands to further their ability to manage systems in JumpCloud. Working with a varied audience of users and environments, we have collaborated to create some "policy" commands for purposes ranging from security to software management.

The commands listed in this article are specific to triggering tasks upon login. You can accomplish the same goal using command launch events Run on Next Login or Run on Every Login. Learn more in Get Started: Commands.

Considerations:

  • Windows 8, Windows Server 2012 or newer is required.
  • ​Scheduled tasks created in this manner will run as the same user that created them.

When configuring Windows commands, you can specify if you would like to run the command execution via PowerShell or CMD. The Logon triggered task must be executed using Windows PowerShell.

  • Select Windows Powershell to run via PowerShell

Execution

In the below example a scheduled task is created called "Test" which will execute "test-script.ps1" upon next login. 

$action = New-ScheduledTaskAction -Execute C:\test-script.ps1
$trigger = New-ScheduledTaskTrigger -AtLogOn
Register-ScheduledTask -Action$action -Trigger $trigger -TaskName "Test" -Description "Testing Scheduled Task API via PowerShell"

This can be viewed in the Task Scheduler snap-in alongside all other scheduled tasks.

Get-ScheduledTask

Back to Top

List IconIn this Article

Still Have Questions?

If you cannot find an answer to your question in our FAQ, you can always contact us.

Submit a Case