Answer the question
In order to leave comments, you need to log in
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
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 :(
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 questionAsk a Question
731 491 924 answers to any question