Part 2 of an earlier question here – I know have a variable which contains a password in plaintext, and a username in plaintext which happens to be a email address. I need to use these in order to send an email via SMTP in powershell, Send-MailMessage for example.
So I need to pass it:
personx@persony.com and $password
In order to authenticate against a smart host the send the email. Any way of doing this, something clever with Get-Credential or some switch on Send-MailMessage, or is there another totally different option?
Cheers
You can use
ConvertTo-SecureStringto convert your plain text password.Assuming your username is in
$usernamevariable and plain text password in$password, you can do something like this: