Solved

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

Posted on 2014-12-16
7
174 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 56

Expert Comment

by:Cliff Galiher
Comment Utility
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
Comment Utility
Because I need it now.  At work will take me 3 weeks to get the task scheduler to be implemented.
0
 
LVL 56

Expert Comment

by:Cliff Galiher
Comment Utility
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:Rad1
Comment Utility
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 56

Expert Comment

by:Cliff Galiher
Comment Utility
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 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
Comment Utility
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
Comment Utility
Excellent!!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

We recently had an issue where out of nowhere, end users started indicating that their logins to our terminal server were just showing a "blank screen." After checking the usual suspects -- profiles, shell=explorer.exe in the registry, userinit.exe,…
Redirected folders in a windows domain can be quite useful for a number of reasons, one of them being that with redirected application data, you can give users more seamless experience when logging into different workstations.  For example, if a use…
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now