title: Powershell script to Check and keep program running
body: <p>Making a short script to keep a program that crashes every now and then running, </p>
  
  <p>Here is what I am trying and been editing </p>
  
  <pre><code>$date = Get-Date -Format G
  
  Function Loop {
  { if(Get-Process -Name notepad -ErrorAction SilentlyContinue) -eq $null
   write-host -ForegroundColor red "Server Is Not Running" 
   .\eldorado.exe -launcher -dedicated -headless -window -height 300 -width 300 
   echo "Guardian Started Headless Eldorito Server $($date)" | Add-Content .\dedicatedServer.log }
  
  
  
   else {write-host -ForegroundColor green "Server Is Running"  
         sleep 10  
         Loop
         }
         Loop
  }
  </code></pre>
  
  <p>What am I doing wrong? / New to scripting / programming </p>