Solved

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

Posted on 2014-12-16
7
181 Views
Last Modified: 2014-12-17
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
0
Comment
Question by:Rad1
  • 3
  • 3
7 Comments
 
LVL 58

Expert Comment

by:Cliff Galiher
ID: 40503724
Why can't you use task scheduler?  That's its job, just like cron on Unix. It is pretty core to the OS.
0
 

Author Comment

by:Rad1
ID: 40503741
Because I need it now.  At work will take me 3 weeks to get the task scheduler to be implemented.
0
 
LVL 58

Expert Comment

by:Cliff Galiher
ID: 40503772
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.
0
Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

 

Author Comment

by:Rad1
ID: 40503917
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?
0
 
LVL 58

Expert Comment

by:Cliff Galiher
ID: 40504068
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.
0
 
LVL 80

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 40504215
wrap your powershell script in the following
$sleeptime = 9 * 60
do {
add your script
start-sleep -seconds  $sleeptime
} while ( 1 -eq 1)
#this is an infinite loop
0
 

Author Closing Comment

by:Rad1
ID: 40505843
Excellent!!!
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Scenario:  You do full backups to a internal hard drive in either product (SBS or Server 2008).  All goes well for a very long time.  One day, backups begin to fail with a message that the disk is full.  Your disk contains many, many more backups th…
Remote Apps is a feature in server 2008 which allows users to run applications off Remote Desktop Servers without having to log into them to run the applications.  The user can either have a desktop shortcut installed or go through the web portal to…
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question