Dear All,
I can use the below script to send mail via GMail:
send-mailmessage -from someone@gmail.com -To Receiver@hotmail.com -Subject "Sending Mail with Attachment" -Body "Hello, Fun with PowerShell and EMail" -Attachments "C:\MyFolder\MyFile.txt" -Priority High -DNO OnSuccess, OnFailure -smtpServer "smtp.gmail.com" -Credential someone@gmail.com
The thing is that, this script will prompt me to enter Password for my GMail account. On the other hand, I have the option to enter password in my above script in plain-text. The problem is that whoever reads the script can know my password.
My question is --- is there anyway I can mention the password in my script in an encrypted format; so that if others are reading my script (or if I share my script) they wont be able to read plain-text password. Password should be written in the script; but not in plain-text.