Get the status for a scheduled task from a list of computers

One of our standards is to have customer computers reboot on a scheduled basis (for windows updates and for system stability for highly used server, i.e. RDS servers). However, we also need them to do certain things when they reboot, like stop certain services, clean out print queue folders, etc. We’ve setup a scheduled task to do this and one of the problems with this is we sometimes lose track of what server is set to do what, when.

Powershell to the rescue!

This script will take a list of computers (one name per line) and get the Scheduled Task Info for each one.

Title: 		Get the Scheduled Task Status for a list of remote computers
Author: 	Michael Kenning (
Version: 	1.0 (release)
Usage: 		.\getRemoteTasks.ps1 [PATH TO LIST OF SERVERS]

Updated: 	26 MAR 2015

param (

# -- Import list of servers
$computers = Get-Content $path

# -- Set the task name to seach for
$taskName = "Reboot"

# -- Loop through the list of computers
Foreach ($computer in $computers) {
	# -- Create a new PowerShell Session to the specified computer
	$session = New-PSSession -ComputerName $computer
	# -- Invoke a remote command with a parameter to pass the Task Name to the command
	Invoke-Command -Session $session -ScriptBlock {
		Get-ScheduledTask -TaskName $taskName | Get-ScheduledTaskInfo
	} -Args $taskName
Tagged with: ,
Posted in Powershell

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: