I am getting the error below, and below that is my script. I'm not a pro at powershell and most of this script came from someone else. In ISE, and I don't know that this matters but thought I'd bring it up, the being quote on line 5 for the email address, is colored brown, and the end quote is colored blue like the email. I actually double quoted the email address on line 5 and got pass the error, but each line with something in quotes failed with the same error. Ultimately, the script did not run after trying all in double quotes. Again sorry for being such a noob, I'm sure it's something simple I'm over looking. It seems to be quite a common error but nothing I found is working. Thanks for your help!
Error
At line:5 char:15
+ $Username = “youremail@gmail.com”
+ ~~~~~~~~~~~~~~~~~~
Unexpected token 'youremail@gmail.com”
$Password = “yourpassword”
$to = “yoursendtoemail@gmail.com”
$subject = “Replica' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
Script
if ((Get-VMReplication | select-string -inputobject {$_.Health} -pattern “Warning”) -like “Warning”)
{
$SMTPServer = “smtp.gmail.com”
$SMTPPort = “587″
$Username = “youremail@gmail.com”
$Password = “yourpassword”
$to = “yoursendtoemail@gmail.com”
$subject = “Replica WARNING error on BDR1”
$message = New-Object System.Net.Mail.MailMessage
$message.subject = $subject
$message.to.add($to)
$message.from = $username
$smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
$smtp.EnableSSL = $true
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
$smtp.send($message)
}
elseif ((Get-VMReplication | select-string -inputobject {$_.Health} -pattern “Critical”) -like “Critical”)
{
$SMTPServer = “smtp.gmail.com”
$SMTPPort = “587″
$Username = “youremail@gmail.com”
$Password = “yourpassword”
$to = “yoursendtoemail@gmail.com”
$subject = “Replica CRITICAL error on BDR1”
$message = New-Object System.Net.Mail.MailMessage
$message.subject = $subject
$message.to.add($to)
$message.from = $username
$smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
$smtp.EnableSSL = $true
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
$smtp.send($message)
}