title: Search Variable for String then Run Conditional Statement in PowerShell
body: <p>I am pretty new with PowerShell. I was recently tasked with making a error message popup that would help a local user determine whether or not a MS SQL on-demand DB merge worked or not. I wrote a script that woudld do the following:</p>
  
  <p><li> Run the batch file that conducted the merge
  <li> Read the results of a text log file into a variable
  <li> Check the variable for any instances of the word "ERROR" and pop a success or fail dialog box depending on whether or not it found the word error in the log file.</p>
  
  <p>Quick and simple I thought but I appear to be struggling with the conditional statement. Here is the script:</p>
  
  <pre><code>cmd /c c:\users\PERSON\desktop\merge.bat
  
  $c = get-content c:\replmerg.log
  
  if ($c -contains ("ERROR"))
  {
      $a = new-object -comobject wscript.shell
      $b = $a.popup(“ERROR - Database Merge“,0,”Please Contact Support”,1)
  }
  
  else
  {
      $a = new-object -comobject wscript.shell
      $b = $a.popup(“SUCCESS - Database Merge“,0,”Good Job!”,1)
  }
  </code></pre>
  
  <p>Right now what happens is that the script runs and just skips to the Success message. I can confirm that simply running the 'get-content' command in powershell will on its own produce a variable that I can then call and show the content of the log file. My script however does not appear as though it is actually checking the $c variable for the word and then popping the error message as intended. What am I missing here? </p>