Get Action Command Line from Scheduled Task using PowerShell

This week I had to find out the command line of a scheduled task from a few hundred machines, to make sure they had received the correct task, deployed from a Group Policy. Well, PowerShell to the rescue. Here is a small PowerShell snippet that will return the command line from a give task:

$TaskName = "ConfigMgr Client Health"
$Actions = (Get-ScheduledTask -TaskName $TaskName).Actions
$CommandLine = "$($Actions.Execute) $($Actions.Arguments)"
Return $CommandLine

Below is the output from running this via a ConfigMgr Run Scripts action

About the author

Johan Arwidmark

5 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments