Home > Powershell > Powershell One-Liners – Process Monitor

Powershell One-Liners – Process Monitor

As a server admin, I often face a situation where I have to perform an action on the server, but some process is running, and I have to wait.

Rather than sitting around checking the server every 5 minutes, I set a Powershell one-liner monitor with notification:

powershell.exe -command "& {if (! (get-process -name TheService -erroraction SilentlyContinue)){Send-MailMessage -SmtpServer 'theSMTPServer.void.null' -from theserver@rack.room -To 'theadmin@void.null -Subject 'TheService is not running, check theServer'}}"

I simply add the above line same as in the Folder cleaner

/theadminguy

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.