Skip to content

Instantly share code, notes, and snippets.

@MarioBinder
Created October 10, 2019 18:06
Show Gist options
  • Select an option

  • Save MarioBinder/a3f0bd87d8b6fb95fb3866f366b9a531 to your computer and use it in GitHub Desktop.

Select an option

Save MarioBinder/a3f0bd87d8b6fb95fb3866f366b9a531 to your computer and use it in GitHub Desktop.
script for monitoring chrome
$target = "chrome"
$process = Get-Process | Where-Object {$_.ProcessName -eq $target}
while ($true)
{
while (!($process))
{
$process = Get-Process | Where-Object {$_.ProcessName -eq $target}
start-sleep -s 5
}
if ($process)
{
"Chrome is running"
$process.WaitForExit()
start-sleep -s 2
$process = Get-Process | Where-Object {$_.ProcessName -eq $target}
"Chrome is shutting down"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment