?
Solved

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

Posted on 2014-12-16
7
Medium Priority
?
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 59

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 59

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
What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

 

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 59

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 82

Accepted Solution

by:
David Johnson, CD, MVP earned 2000 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

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…
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
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 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…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

762 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