So I have a encrypted string stored in a text file that I can call again and again, this is the password for my SMTP Smart Host. This is created via:
Read-Host "Enter the Password:" -AsSecureString | ConvertFrom-SecureString | Out-File C:\EncPW.bin I now need to somehow pass this along with a $username to a -Credential parameter for a Send-MailMessage function. I assume I need to get this into a PSCredential format. But I'm stuck !
$password = cat C:\encPW.bin | ConvertTo-SecureString $password $cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username,$password As of now I have this, but it $password when I print it outputs System.Security.SecureString and I get an error:
net_io_connectionclosed When it tries to SMTP send.
Cheers
CALL to SMTP Send:
Send-MailMessage -from "[email protected]" -To "[email protected]" -Subject "Daily Report" -Body "Open Attachment for Report" -smtpServer 85.119.248.54 -Attachments "C:\WSB_Reports\DailyReport.txt" -Credential $cred
Send-MailMessage .... -Credential $cred? Is this what outputs the error?$creds = Get-Credential