Hi,
You should define a variable before using it otherwise the variable is null.
$status = Get-VMReplication | Select-Object Name, State, Health, Mode, FrequencySec, PrimaryServer, ReplicaServer, ReplicaPort | ConvertTo-Html
$User = "******@mydomain.org"
$PWord = Get-Content "C:\temp\hyper-v.zip" | ConvertTo-SecureString -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
Send-MailMessage -To ******@mydomain.org -from ******@mydomain.org -Subject 'Hyper-V Replication Status' -Body "$status" -BodyAsHtml -smtpserver smtp.office365.com -usessl -Port 587 -Credential $Credential
Best Regards,
Ian
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.