Skip to content

Instantly share code, notes, and snippets.

@markwragg
Created October 12, 2016 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markwragg/189bbc20c5f0d7708db747abdbf19e87 to your computer and use it in GitHub Desktop.
Save markwragg/189bbc20c5f0d7708db747abdbf19e87 to your computer and use it in GitHub Desktop.
Powershell script for communicating a list of credentials to users by email. Beware these credentials are therefore communicated in plain text.
[CmdletBinding()]
Param(
[CmdletBinding(SupportsShouldProcess = $true)]
$Inputfile
)
Import-CSV Credentials.csv | ForEach-Object {
$Body = "Dear $($_.GivenName),
Please find your credentials below:
Account name: $($_.AccountName)
Password: $($_.Password)
Regards,
YourName"
If ($PSCmdlet.ShouldProcess("$($_.EmailAddress)","Send email with credentials")){
Write-Progress -Activity "Sending credentials by email" -Status "Sending credentials to $($_.EmailAddress)"
Send-MailMessage -To $_.EmailAddress -From "donotreply@yourdomain.com" -SmtpServer "mail.yourdomain.com" -Subject "Credentials for $($_.GivenName)" -Body $Body
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment