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

Monitor a process on NT box
Last Post 14 May 2008 07:26 PM by chris.harrod. 9 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
aalborzUser is Offline
New Member
New Member
Posts:56

--
14 May 2008 02:59 PM  

Can PS monitor a process on an NT server box? Would it require PS to be installed locally on the box or can it be done remotely (the preferred method)?

If so, I'd like to see how to put together a script, so it monitors a process's status and when it changes, it will send an email notification.

TIA

Alex

 

aalborzUser is Offline
New Member
New Member
Posts:56

--
14 May 2008 06:02 PM  

I got this working myself...well kind of.

I used the Get-WmiObject  Win32_Process, instead of the Get-Process command. It works on few NT boxes, but not all. I get an error message about Class not being registered.

Appreciate any help!

Alex

 

 

chris.harrodUser is Offline
New Member
New Member
Posts:4

--
14 May 2008 06:15 PM  
Hopefully this works.


$service = get-service -ComputerName lfi-fs-EDIT -include Alerter

if ($service.Status -eq "Stopped"){
    $emailFrom = "chris.harrod@edit.edit"
    $emailTo = "chris.harrod@edit.edit"
    $subject = "Service has enetered stop state."
    $body = "Service has enetered stop state."
    $smtpServer = "LFI-CS-EDIT.EDIT"
    $smtp = new-object Net.Mail.SmtpClient($smtpServer)
    $smtp.Send($emailFrom, $emailTo, $subject, $body)
}
chris.harrodUser is Offline
New Member
New Member
Posts:4

--
14 May 2008 06:16 PM  

That's just something I threw together really quick.  You could set it up as a scheduled task on the server and go from there.

I'm sure there are other ways to accomplish the same task.

halr9000User is Offline
Basic Member
Basic Member
Posts:303

--
14 May 2008 06:28 PM  
If you want something to work at an interactive real-time fashion, then you ought to do that via code executing or triggering locally on the box, that's just good architecture. If you don't mind polling at 5, 10, 60 min intervals, you can do it remotely. If you poll remotely, you could do that by using the Get-WmiObject cmdlet like so:

get-wmiobject win32_process -computer

aalborzUser is Offline
New Member
New Member
Posts:56

--
14 May 2008 06:28 PM  

Thanks, but I wanted to monitor a process not a service. I'm familiar with doing both using PS.

I just wanted to know if there's anything can be done for a NT box specifically. Like I said in my earlier post, I got it working, but it doesn't work on couple of NT servers.

aalborzUser is Offline
New Member
New Member
Posts:56

--
14 May 2008 06:32 PM  

halr9000,

That's exactly how I got it working, using two functions: one for email and one for checking whether the process is running. Remotely, it goes through a counter of 4, sleeps for 60 second, and starts again.

It's working ok, but not on couple of NT servers. I'm trying to resolve that part.

Thx

Alex

 

 

halr9000User is Offline
Basic Member
Basic Member
Posts:303

--
14 May 2008 07:00 PM  
Just to be sure--you are aware that NT is older than dirt, and has more holes than swiss cheese, right?
aalborzUser is Offline
New Member
New Member
Posts:56

--
14 May 2008 07:21 PM  

Yes sir. We've been down that road many times. The application won't run on anything else and it also requires Outlook 98.

We have newer version of it running on W2K & W2K3 boxes, but this one is used for supporting clients old projects, which won't go away any time soon, if ever.

chris.harrodUser is Offline
New Member
New Member
Posts:4

--
14 May 2008 07:26 PM  
If NT were a sponge it would soak up the internet and its clogged tubes.
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