This script uses the Get-ADUser cmdlet to retrieve user accounts that are enabled, have a set expiration date, and are expiring within the next 7 days. It then loops through the accounts and adds their name, email address, and expiration date to an HTML table in the email body. Finally, the script sends the email using the Send-MailMessage cmdlet, specifying the SMTP server, sender address, recipient address, subject, HTML body, and the -BodyAsHtml parameter to indicate that the email body is in HTML format.