title: Passing Variables to Send-MailMessage
body: <p>I'm trying to create a PowerShell script that will search my Active Directory for users with passwords that will expire in 14 days and email the user a reminder message. For the most part I have the script working as intended, but I am not getting the proper output for the emails.</p>
  
  <p>This is the script:</p>
  
  <pre><code>Import-Module ActiveDirectory
  $below = (Get-Date).AddDays(-77)
  $above = (Get-Date).AddDays(-76)
  $Persons = Get-ADUser -Filter {PasswordNeverExpires -eq $False -AND (PasswordLastSet -lt $above -AND PasswordLastSet -gt $below) -AND (LastLogonDate -like "*") -AND (MAil -like "*")}
  
  foreach ($Person IN $Persons) {
  $body = "Your Windows password will expire in 14 days. Please consider changing your password. - $User.Name - $User.PasswordLastSet"
  Send-MailMessage -To $User.Mail -Subject "Alert! Password Expiring Soon!" -From 'Do_Not_Reply@domain.com' -Body $body -SmtpServer smtp.server.com
  }
  </code></pre>
  
  <p>This is what I am getting in the body of the mails it sends. </p>
  
  <blockquote>
    <p>Your Windows password will expire in 14 days. Please consider changing your password. - .Name - .PasswordLastSet</p>
  </blockquote>
  
  <p>How do I pass the users name and password last set data to the body text?</p>