Does anyone have an idea on how to fix this issue. I'm working on automating new user creation and notification in Active Directory (AD). I have written a PS script to import & create new users from a CSV file in PowerShell and I will like to communicate the "userid" and password to each of the users using PS Send-MailMessage option.
Below script handles this fine, but the format is not looking good, as you can see on the attachment.
Actually, there are two issues, that I'm trying to resolve.
$SupportEmail = "email@example.com" $To = "$EmailAddress" $Cc = " firstname.lastname@example.org"" $Attachment = "C:\Accountsetup.pdf" $subject = "Welcome - Account Setup Credentials $SMTPServer = "smtp.gmail.com" $SMTPPort ="587" $body = "Hello $DisplayName," $body += "This e-mail contains your user name and first-time password for signing into our web service" $body += "Acount UserName: $SamAccountName@exampledomain.com" $body += "Temporary Password: $Password" $body += "Please see the attached userguide on how to reset your password using your temporary assigned password " $Creds = (Get-Credential -Credential "$SupportEmail") Start-Sleep 2 Send-MailMessage -From $SupportEmail -to $To -cc $Cc -Attachment $Attachment -Subject $Subject ` -Body $Body -SmtpServer $SMTPServer -Port $SMTPPort -UseSsl ` -Credential $Creds -DeliveryNotificationOption never