How to Terminate Processes in Time-Controlled Manner Via PowerShell

How to Terminate Processes in Time-Controlled Manner Via PowerShell

With the help of the task scheduler and the Windows PowerShell, services and processes can be terminated in a time-controlled manner.

There are many reasons why a specific process or service must be terminated: Performing a consistent data backup or restarting a service at a specific time.


A recurring case from my practice is, for example, the application CodeTwo Email Signatures in combination with a Windows terminal server. The client, which reliably imports the signatures into the user profiles, can only be run by one user at a time on the terminal server. This means: whoever logs in first will receive the current signature changes. Everyone else doesn’t because the process is already in use. Here I help myself to end the process with the PowerShell time-controlled. This is then available again for the next logins.

The command to kill a process is stop process. The complete command to exit (e.g., from Microsoft Outlook) is:

Stop-Process -Name Outlook

In combination with the Windows task scheduler, the whole thing looks like this:

  How to Delete Empty Folders Using Powershell

In this way, processes can be terminated to the second. For example, in the example above, I automatically terminate the Email Signatures with a one-minute delay at each user login. This period of time is sufficient to update the signatures before the process is terminated again.

If the processes of other users are to be terminated, the parameter -force to add. This suppresses the prompt before exiting. If this parameter is missing, the task will not be completed because PowerShell waits for input in the background.

The full command would then be:

Stop-Process -Name Outlook -force

To be able to terminate processes in a time-controlled manner, no complicated scripts are required. The starting of processes is also included start process possible.

Important: The example above kills ALL processes with the given name. On systems where multiple users are logged on, all active users’ processes of the same name would be terminated. Here it is recommended to use the command with the parameter -ID instead of -Name and to specify the corresponding process ID.

Rohit is a certified Microsoft Windows expert with a passion for simplifying technology. With years of hands-on experience and a knack for problem-solving, He is dedicated to helping individuals and businesses make the most of their Windows systems. Whether it's troubleshooting, optimization, or sharing expert insights,