myITforum.com Community Forum myITforum.com Community Forum

Home  Forums  Blogs  Live Support chat  Search Articles  Wiki  FAQ  Email Lists  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Photo Gallery  Member List  Search  Calendars  FAQ  Ticket List  Log Out

All Forums RSS Feed Subscription:


  


Monitoring Powershell

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
  Printable Version
All Forums >> [Scripting Technologies] >> Windows PowerShell >> Monitoring Powershell Page: [1]
Login
Message << Older Topic   Newer Topic >>
Monitoring Powershell - 8/22/2008 11:21:18 AM   
gmaynard

 

Posts: 23
Score: 0
Joined: 9/9/2004
Status: offline
I have written a PS script (v 1.0) that is running as a service via srvany.exe. I have error trapping blocks throughout the script. After a day or so of running, the script appears to stop working. The process is still running (both Powershell and srvany), but I am no longer seeing the expected output. The errors I am trapping do not appear to be catastrophic nor time-related to when the script stops working. No errors appear after the script stops processing. Also, I did a perfmon trace and I did not see anything that stood out as to a stopping point for the script.

Any ideas on how I can monitor when / how the script is failing?
Post #: 1
RE: Monitoring Powershell - 8/27/2008 9:39:46 AM   
SAPIENScripter

 

Posts: 100
Score: 0
Joined: 5/15/2007
From: SAPIEN Technologies
Status: offline
First off, running any sort of a script as a service isn't recommended.  Script engines and scripts simply aren't designed for that task and the problem you are having is a prime example of why. What happens if you run the script interactively and let it run for a day or so?  Do you get the same problems or an actual error message?  That would be the first thing I would try.

_____________________________

Jeffery Hicks
Microsoft MVP - Windows PowerShell
http://blog.SAPIEN.com
coming soon: Managing Active Directory with Windows PowerShell: TFM
followme: http://www.twitter.com/jeffHicks

(in reply to gmaynard)
Post #: 2
RE: Monitoring Powershell - 8/27/2008 11:07:36 AM   
gmaynard

 

Posts: 23
Score: 0
Joined: 9/9/2004
Status: offline
I have let the script run interactively for 3+ days without issue. All of the errors I encountered during this testing were successfully trapped. This is why I am now looking for any way to monitor the script from the outside. The process is robust enough that it could recover if I could restart the script after it fails. I just need a trigger to restart it.

(in reply to SAPIENScripter)
Post #: 3
RE: Monitoring Powershell - 8/27/2008 11:44:46 AM   
SAPIENScripter

 

Posts: 100
Score: 0
Joined: 5/15/2007
From: SAPIEN Technologies
Status: offline
So it only fails when run as a service?  If so that's exactly the point I'm making.  If you wanted to see what is happening, you might try adding Start-Transcript to your script.  I don't know how this will work when run as a service.  Otherwise you can add debug or trace code to write what the script is doing periodically to a text file.

_____________________________

Jeffery Hicks
Microsoft MVP - Windows PowerShell
http://blog.SAPIEN.com
coming soon: Managing Active Directory with Windows PowerShell: TFM
followme: http://www.twitter.com/jeffHicks

(in reply to gmaynard)
Post #: 4
RE: Monitoring Powershell - 8/27/2008 1:10:26 PM   
gmaynard

 

Posts: 23
Score: 0
Joined: 9/9/2004
Status: offline
Thanks anyway. I guess I will call the script from the task scheduler rather than putting it in an infinite loop. That should work as a work-around until I can get it re-written as a compiled application.

(in reply to SAPIENScripter)
Post #: 5
RE: Monitoring Powershell - 8/27/2008 1:16:14 PM   
SAPIENScripter

 

Posts: 100
Score: 0
Joined: 5/15/2007
From: SAPIEN Technologies
Status: offline
That's a much better solution.

_____________________________

Jeffery Hicks
Microsoft MVP - Windows PowerShell
http://blog.SAPIEN.com
coming soon: Managing Active Directory with Windows PowerShell: TFM
followme: http://www.twitter.com/jeffHicks

(in reply to gmaynard)
Post #: 6
Page:   [1]
All Forums >> [Scripting Technologies] >> Windows PowerShell >> Monitoring Powershell Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts



  
Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

4.766