Created
October 12, 2016 07:53
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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