Link to home
Start Free TrialLog in
Avatar of patriots
patriots

asked on

Powershell script to check for running process, and email if it is running

I'd like to know of a way to script the following preferably in pshell:
1. Check for a running process.
2. If it's running, send message to SMTP address.
3. Leverage task scheduler - I know that I can do SMTP alerting in Task Manager, and I know about "Get-Process", I just don't know how to tie it all together.

Thanks!!
ASKER CERTIFIED SOLUTION
Avatar of slidingfox
slidingfox
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
get-process is able to use wildcards. So if we always search with wildcards, no error condition will be met if the process does not run. Instead of using the function above, we can also call either
  get-process notepad*
or
  get-process notepad -ea SilentlyContinue
as condition.
Avatar of patriots
patriots

ASKER

what about running this from a job server with a remote server as the target for the script?  Both the source and target both contain pshell v2.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please explain why you chose http:#a37853074 and http:#37854263 as (only) answers, in particular since I have simplified/improved those, and gave additional feedback to your follow-up question.