Skip to content

Instantly share code, notes, and snippets.

@RustyNails8
Created February 19, 2019 02:02
Show Gist options
  • Save RustyNails8/4b7187849991743fbaaab5621d043753 to your computer and use it in GitHub Desktop.
Save RustyNails8/4b7187849991743fbaaab5621d043753 to your computer and use it in GitHub Desktop.
Send Mail Powershell
<# Encrypted AES Key and Password as Secure String are stored on \\myUNCpath #>
$encryptedSecureKey = Get-Content \\myUNCpath\smtpKEY.txt
$encryptedSecureString = Get-Content \\myUNCpath\smtprelay.txt
$secureKey = ConvertTo-SecureString -String $encryptedSecureKey
$secureString = ConvertTo-SecureString -String $encryptedSecureString -SecureKey $secureKey
$cred = New-Object System.Management.Automation.PSCredential('Domain\User', $secureString)
Send-MailMessage -from 'azure-noreply@domain.com' -To 'sumit.das@domain.com' -Subject 'TEST mail for VM Action' -Body 'TEST VM Action Mail Bidy' -SmtpServer 'smtp.domain.com' -Credential $cred
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment