Home ยป PowerShell ยป PowerShell Enable Scheduled Task on Remote Computer

PowerShell Enable Scheduled Task on Remote Computer

Use the PowerShell command `Enable-ScheduledTask` with the `CimSession` object that contains the remote computer connection to enable a scheduled task on a remote computer.

The Enable-ScheduledTask cmdlet enables the scheduled task. Enabling a task runs the task if the scheduled task is disabled on the computer. The CimSession object contains information about a remote computer connection.

In this article, we will discuss how to enable scheduled tasks on a remote computer.

Enable Remote Scheduled Tasks in PowerShell

Using the PowerShell script, the Enable-ScheduledTask cmdlet enables the scheduled tasks remotely. It takes the CimSession object that contains the remote computer connection information.

# Create remote computer connection using New-CimSession
$session = New-CimSession -ComputerName "corpit-euc-101"

# Enable the scheduled tasks on remote computer

Enable-ScheduledTask -CimSession $session -TaskName "Adobe Acrobat Update Task"

In the above PowerShell script, the New-CimSession cmdlet creates a new connection with the remote computer specified using the ComputerName property and stores the connection details in the $session CimSession object.

The Enable-ScheduledTask cmdlet uses the CimSession object to connect to a remote computer and enable scheduled tasks where TaskName is equal to the specified name.

The output of the above PowerShell script to enable a scheduled task on a remote computer is:

PS C:\> Enable-ScheduledTask -CimSession $session -TaskName "Adobe Acrobat Update Task"
                                
TaskPath    TaskName                                       State          PSComputerName
--------           --------                                                -----             --------------
\                   Adobe Acrobat Update Task         Enabled   corpit-euc-101

Another way to enables a scheduled task is to get the list of scheduled tasks remotely using the Get-ScheduledTask command, use the Where clause to filter the required task name, and use the Enable-ScheduledTask command to enable a scheduled task remotely.

$session = New-CimSession -ComputerName "corpit-euc-101

Get-ScheduledTask -CimSession $session | Where {$_.TaskName -like "Adobe*"} | Enable-ScheduledTask

The output of the above command enables a scheduled task remotely.

PowerShell Enables a Scheduled Task on Remote Computer
PowerShell Enables a Scheduled Task on Remote Computer

PowerShell Enable Scheduled Task in Folder Remotely

Use the Enable-ScheduledTask cmdlet in PowerShell to enable all scheduled tasks in a folder retrieved using the Get-ScheduledTask command.

$session = New-CimSession -ComputerName "corpit-euc-101
Get-ScheduledTask -CimSession $session -TaskPath "\Mozila\" | Enable-ScheduledTask

n the above PowerShell script, the New-CimSession cmdlet creates a new connection with a remote computer and stores the connection details in the CimSession object $session.

The Get-ScheduledTask command uses the CimSession parameter to connect to a remote computer and list all the scheduled tasks in a folder specified by the TaskPath parameter. It pipes the information to the Enable-ScheduledTask cmdlet which enables all scheduled tasks in a folder.

Conclusion

I hope the above article on how to enable scheduled tasks on a remote computer using the PowerShell command Enable-ScheduledTask is helpful to you.

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