Home » PowerShell » PowerShell Get Scheduled Task Actions Details

PowerShell Get Scheduled Task Actions Details

Use the command `Get-ScheduledTask` with its property Actions to get the scheduled task action details in PowerShell.The `Actions` property of a task represents the actions that will be taken when the task is run.

( Get-ScheduledTask -TaskName "UserTask").Actions

The Get-ScheduledTask cmdlet in PowerShell retrieves the list of Tasks and information.

In this article, we will discuss how to get scheduled task action details and list scheduled tasks and actions using a PowerShell script.

PowerShell Get Scheduled Task Action Details

The Get-ScheduledTask command in PowerShell gets all scheduled task details. It uses the TaskName property to filter the scheduled task to retrieve only specified scheduled task information.

( Get-ScheduledTask -TaskName "UserAccountTests").Actions

In the above PowerShell script, the Get-ScheduledTask cmdlet uses the property Actions to get scheduled task action details for the specified task name “UserAccountTests“

The output of the above PowerShell script is:

Get Scheduled Task Actions in PowerShell
Get Scheduled Task Actions in PowerShell

The output of the scheduled task actions contains the Arguments for the given task which is the PowerShell script path and Execute property has powershell.exe to execute the action when the task is run.

List Scheduled Task Actions Details in PowerShell

The command to get scheduled task actions details in PowerShell is Get-ScheduledTask. This command retrieves the existing scheduled tasks and uses the Actions property to get actions associated with each task.

( Get-ScheduledTask).Actions | Format-List *

In the above PowerShell script, the Get-ScheduledTask cmdlet uses the Actions property. This command lists scheduled tasks and actions.

Output for each task displays the task property like Id, Arguments, Execute Working Directory, etc…

PS C:\> ( Get-ScheduledTask).Actions | Format-List *

Id                    :
Arguments             : /checkrecovery
Execute               : %SystemRoot%\System32\dsregcmd.exe
WorkingDirectory      :
PSComputerName        :
CimClass              : Root/Microsoft/Windows/TaskScheduler:MSFT_TaskExecAction
CimInstanceProperties : {Id, Arguments, Execute, WorkingDirectory}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties

Id                    :
Arguments             : wwan
Execute               : %SystemRoot%\System32\WiFiTask.exe
WorkingDirectory      :
PSComputerName        :
CimClass              : Root/Microsoft/Windows/TaskScheduler:MSFT_TaskExecAction
CimInstanceProperties : {Id, Arguments, Execute, WorkingDirectory}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties

Id                    :
Arguments             : standby
Execute               : %windir%\System32\XblGameSaveTask.exe
WorkingDirectory      :
PSComputerName        :
CimClass              : Root/Microsoft/Windows/TaskScheduler:MSFT_TaskExecAction
CimInstanceProperties : {Id, Arguments, Execute, WorkingDirectory}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties

Id                    :
Arguments             : do-task "308046B0AF4A39CB"
Execute               : C:\Program Files\Mozilla Firefox\default-browser-agent.exe
WorkingDirectory      :
PSComputerName        :
CimClass              : Root/Microsoft/Windows/TaskScheduler:MSFT_TaskExecAction
CimInstanceProperties : {Id, Arguments, Execute, WorkingDirectory}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties

Cool Tip: How to delete a scheduled task in PowerShell!

Conclusion

I hope the above article on how to get scheduled task action details and list scheduled task actions in PowerShell is helpful to you.

Schedule task Actions details can be retrieved using the ScheduledTask cmdlet as well.

 (ScheduledTask -TaskName "UserAccountTests").Actions

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.

Leave a Comment