I would like to run a powershell command:
Get-Process "auto ftp manager" | Where StartTime -lt (Get-Date).AddMinutes(-30) | Stop-Process -Force
every 12 hours on a server automatically.
I was thinking to use a batch file and windows scheduler to run it.
How do I make the powershell command run from a batch file?
Is there a better solution to achieving this task, i.e. running the ps command automatically every 12 hours?
PowershellFTPWindows OS
Last Comment
Attila Mosonyi
8/22/2022 - Mon
Ryan Chong
you can call a powershell script via task scheduler directly without the use of batch file.
Attila Mosonyi
ASKER
Hi Ryan, I need help with creating the powershell script for:
Get-Process "auto ftp manager" | Where StartTime -lt (Get-Date).AddMinutes(-30) | Stop-Process -Force
As I mentioned before, I don't have any experience/knowledge with powershell, so please someone help me with creating a script (.ps1) for the following:
Get-Process "auto ftp manager" | Where StartTime -lt (Get-Date).AddMinutes(-30) | Stop-Process -Force
Putting the commandlet simply into a *.ps1 doesn't do the job.
I tested it by simply running it manually. It only completes the job, when the powershell is running in elevated mode, i.e. as administrator. So how do I put this in the *.ps1?
oBdA
Again the same as in batch/cmd.exe (or any other program that requires elevation); you start a PS console by right-clicking the shortcut and select "Run as Administrator", and run the script from there.
When scheduling the task, you have a checkbox option "Run with highest privileges", or you just use the System account to run the task under.
Attila Mosonyi
ASKER
Thank you Ryan Chong and oBdA very much for your assistance :)