#1 21 Jul 2012 21:08

Registered: 21 Jul 2012
Posts: 1

how to write powershell to identify running processes


I am preety new to powershell scripting i need help.

I want to write script which search that which processes are running from the taskmanager and if the process are not running then send mail.

There are 4 processes so i want to check this in one program and i have to use config file to generalise the program

Please help to resovle this.

Till now i tried

set process_1 = "D:\test\abc.exe " -AL -UN="xxxxxxx" -PW="xxxxxxx" -OLEAPI
set process_2 =  D:\auto\auto.exe
set process_3 = "D:\abc.exe " -AL -UN="xxxxxxx" -PW="xxxxxxxx." -WFSRVR ODBC
set process_4 =  D:\copy.exe

WMIC /OUTPUT:C:\ProcessList.log path win32_process where name="abc.exe"
Type ProcessList.log > found.log
FOR /F %%A IN (found.log)
     set var1 = %%A
     If /I var1 NEQ process_1
     echo abc process is not running properly....

Else (
     echo Autoarchive Broker is running....
goto end



#2 11 Sep 2012 15:09

Registered: 10 Sep 2012
Posts: 3

Re: how to write powershell to identify running processes

The Powershell way to lookup processes is by using Get-Process

Get-Process $ProcessName -ErrorAction SilentlyContinue > $Nul

If (!($?)){
    Write-host "$ProcessName is NOT running"
} else {
    Write-host "$ProcessName is running"

If you want to look up the path of each running process.

foreach ($OneProcess in $AllProcesses) {
	echo $OneProcess.path


Board footer

Powered by FluxBB