header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Running .ps1 as Service
Last Post 05 Feb 2008 04:07 PM by RichS. 3 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
DannyUser is Offline
New Member
New Member
Posts:10

--
05 Feb 2008 07:16 AM  

Hey Guys,

after i wrote a couple of scripts i want to implement them on a couple of server. The aim is that the scripts run every 5-10minutes again.

My 2 main options at the moment are:

- Running the Script by using scheduled task

- Creating a service who uses the script

 

For the first version i already have the solution but i want to learn as much as possible and could need a hint for my 2nd option.

 

Thanks in advance

halr9000User is Offline
Basic Member
Basic Member
Posts:303

--
05 Feb 2008 01:10 PM  
I recommend using scheduled tasks. The reason is that a script running as a service won't be able to properly respond to events as a service is expected to, leading to weird errors and possible unintended consequences. But you can do it...you can use srvany from the Windows Resource Kit. Also, search the powershell newsgroup (microsoft.public.windows.powershell) via google or microsoft.com on this topic, it has come up before.
DonJUser is Offline
PowerShell MVP
Basic Member
Basic Member
Posts:134

--
05 Feb 2008 03:55 PM  
PowerShell is definitely not designed or tuned to be run as a service - you'd likely be disappointed. I agree that a schedule task is probably the best way to go. If you wanted to create a service that performed well, you'd need to use C# or Visual Basic - .NET can author a proper service, and C# or VB could instantiate PowerShell and run scripts every time a timer "timed out," for example.
RichSUser is Offline
New Member
New Member
Posts:41

--
05 Feb 2008 04:07 PM  

While agreeing that a scheduled task is the best approach.  In the interest of completeness there is a tool in the Windows resource kit called srvany.exe that may halp run PS as a service.  I haven't tried it but I would still prefer the scheduled task.

You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer