Use the `Get-ScheduledTask` cmdlet in PowerShell to get the scheduled tasks on the remote computer with the `CimSession` object that contains the remote computer connection. It retrieves and list scheduled tasks on the remote computer.
The Get-ScheduledTask command retrieves the existing scheduled task on the local or remote computer. The CimSession ( Common Information Model) object specifies the remote computer connection details.
In this article, we will discuss how to get a list of scheduled tasks on the remote computer using the PowerShell Get-ScheduledTask command.
List Scheduled Tasks on the Remote Computer
The command to get a list of scheduled tasks on the remote computer is Get-ScheduledTask. It uses the CimSession
object that contains the remote computer connection details.
# Create a connection to a remote computer and store it in cimsession object $session = New-CimSession -ComputerName "corpit-euc-101" # Use the Get-ScheduledTask to use cimsession obect to list scheduled task for remote Get-ScheduledTask -CimSession $session | Where {$_.TaskPath -eq "\"}
The New-Session cmdlet in PowerShell creates a CIM session that contains the information about a remote computer specified by the ComputerName
property and stores the connection details in the $session
object.
The Get-ScheduledTask cmdlet uses the CimSession
parameter to use the client-side object to get the list of scheduled tasks on the remote computer from the root folder.
The output of the above PowerShell script to retrieve the scheduled task from the remote computer is:
It lists the scheduled task and their details TaskPath, TaskName, State, and PSComputerName.
PowerShell Get Scheduled Task on Remote Computer
Use the Get-ScheduledTask cmdlet in PowerShell that uses the TaskName
parameter to specify the task name and CimSession
object to get scheduled task details on a remote computer.
# Create a connection with remote computer $session = New-CimSession -ComputerName "corpit-euc-101" # Get specific scheduled task on a remote computer Get-ScheduledTask -CimSession $session | Where {$_.TaskName -like "Adobe*"}
In the above PowerShell script, the $session
object contains information about the connection to a remote computer.
The Get-ScheduledTask cmdlet uses the CimSession
parameter to specify the remote computer connection and get a scheduled task on a remote computer that has TaskName like Adobe *
The output of the above PowerShell script to retrieve the scheduled task details from the remote computer is:
PS C:\> Get-ScheduledTask -CimSession $session | Where {$_.TaskName -like "Adobe*"}
TaskPath TaskName State PSComputerName
-------- -------- ----- --------------
\ Adobe Acrobat Update Task Ready corpit-euc-101
Cool Tip: How to disable scheduled task on a remote computer using PowerShell!
Conclusion
I hope the above article on how to list scheduled tasks on the remote computer and get a specific scheduled task from the remote computer is helpful to you.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.