Avatar of Rad1
Rad1
 asked on

How to run Power Shell script on a web server (Windows 2008 R2)

Hello,

I have a Power Shell Script that I need to run every 9 minutes.  
If I put it on a file share, how can I get the script to run every 9 minutes without using Windows Task Scheduler.
Is there a way to make it run by itself?

Windows Server 2008 R2
Microsoft Server OSWindows Server 2008

Avatar of undefined
Last Comment
Rad1

8/22/2022 - Mon
Cliff Galiher

Why can't you use task scheduler?  That's its job, just like cron on Unix. It is pretty core to the OS.
Rad1

ASKER
Because I need it now.  At work will take me 3 weeks to get the task scheduler to be implemented.
Cliff Galiher

Well firing off a script "now" is possible if WinRM is enabled. But the "repeat every 9 minutes" will require task scheduler. That's what it is there for. The only other way would be to deploy software that does what task scheduler does, and then you are in the same boat of not being able to do that "now" as it isn't core to the OS...it'd be a full software deployment.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Rad1

ASKER
What about creating a clock script and in the script, set a function to run every 9 minutes to run the Power Shell script.  Would that work?
Cliff Galiher

Not well. Scripts don't handle waits well. They basically brute force it by either forcibly throwing idle commands at a processor, which will kill performance of other threads, or by going to sleep, which isn't exact as to when the processor will return to check on the thread. The execute won't necessarily at 9 minutes, but sometime thereafter. If it were that easy, there'd be no need for a task scheduler.
ASKER CERTIFIED SOLUTION
David Johnson, CD

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Rad1

ASKER
Excellent!!!
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.