F
F
frvrndvr2014-12-08 08:11:40
PowerShell
frvrndvr, 2014-12-08 08:11:40

Powershell process check?

Good afternoon!
It is necessary to periodically check: If Notepad is running with an active Internet connection, execute the net send command.
How to do it in powershell?
Thanks to!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2014-12-08
@bk0011m

Is google not working? bit.ly/1vuSmcV - first link

F
frvrndvr, 2014-12-08
@frvrndvr

IF ((Get-WmiObject Win32_PingStatus -Filter 'Address="8.8.8.8"').StatusCode -eq 0) {
write-host -ForegroundColor Green 'ping ok'
IF (Get-Process notepad.exe -ErrorAction SilentlyContinue){
Start -Process mspaint
}
ELSE{
Start-Process wordpad
}
}
else {
write-host -ForegroundColor Red 'ping - down'
}
internet test passes, but scratches notepad check :(

S
Sergey SA, 2014-12-08
@resetsa

IF (Get-Process notepad.exe -ErrorAction SilentlyContinue)
if there is no process, returns an exception and then you need to either try to process it or something like this
if (get-process|?{$_.processname -contains 'notepad'}){ start-process mspaint}
else {start-process wordpad}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question