Powershell script for new account creation - reset password, send email and add to group


I'm looking to optimize and finish one of our scripts following need:

Either on the event AD account creation or once per day with a search filter all new accounts need to:

* Reset a password

* add to a group

* send an email to the new user.

Accounts are created by an external system, so account creation is NOT needed.

Just that the accounts are provisioned with a temp password which we don't know.

And we would like to send a welcome email with a PDF attached to the newly created accounts.

The trigger either being the Active directory account creation or in the morning with a scheduled task emailing all accounts created D-1

We have a basis, that you can use (or not):

##Beginning of functions

Function Send-Email {

Param ($Email, $Credential,$attachment)

$From = "Hello@[login to view URL]"

$subject = "Welcome to CompanyX"

$SMTPServer = "[login to view URL]"

$SMTPPort = "587"

### Beginning of email body

$Body = "Hello New user!,<br><br>"

$Body += "Welcome to CompanyX! <br><br>"

$Body += " This email will help you log in to Workday and Azure update your personal information before you start. <br><br>"

$Body += "Step 1. Enter your username (username)<br><br>"

$Body += "Step 2. Enter your password $UserPassword <br><br>"

$Body += " Please refer to the attached PDF for more information <br><br>"

$Body += "<br><br>"

$Body += "Looking forward to see you around,<br><br>"

$Body += "CompanyX Corporate "

### End of email body

Send-MailMessage -from $From -to $Email -Subject $subject -BodyAsHtml $Body -Attachments $attachment -SmtpServer $SMTPServer -Port $SMTPPort -Credential $Credential -UseSsl


### End of Functions

##### Beginning of main function

$When = ((Get-Date).AddDays(-1))

$UserName = "hello@[login to view URL]" #Gmail username which is used for sending an email

$Password = Get-Content "C:\CareBears\[login to view URL]" | ConvertTo-SecureString #Reading a secure password from file and reversing it back into a secure string object

$Credential = New-Object -TypeName [login to view URL] -ArgumentList ($UserName, $Password) #PSCredential for send-mail message cmdlet

$Attachment = "C:\CareBears\[login to view URL]" #PDF sending as an attachment with email

### Not finished ---- WIP

### $UserPassword = Get-Random -maximum 20000 -Minimum 100

### $UserPassword = "@" + "user" + $[login to view URL]()

### $UserPrincipalName = ($[login to view URL] + ”@[login to view URL]”)

foreach ($EmailAddress in Get-ADUser -filter {(whencreated -ge $When)} -Properties emailaddress | Select -ExpandProperty emailaddress) #Iterating over each email of users


Send-Email -Email $EmailAddress -Credential $Credential -attachment $Attachment

Write-Host "Email sent: $EmailAddress"


### End of main function

Taidot: Powershell, Windows Server, Active Directory

Näytä lisää: powershell script to create users in active directory, powershell reset password multiple users, powershell create ad user from csv, automating active directory account creation with powershell, powershell script to create ad users and mailbox, how to create bulk users in active directory using .csv file, powershell create ad user in ou, powershell create ad user and add to group, forgot password send email, powershell script users creation, active directory account creation powershell, send email yahoo group without permission, powershell script create account, aspnet reset password send email, active directory account creation script, bot gmail account creation script, script imacro use different username account creation, php reset password script, create script reset password, email account creation script

Tietoa työnantajasta:
( 3 arvostelua ) Paris, France

Projektin tunnus: #21800226

Myönnetty käyttäjälle:


Hello. I am an English speaking American. I have been writing Powershell for several years and my day job is actually as an enterprise systems administrator. This type of task is not far off from the stuff I have to de Lisää

€50 EUR 2 päivässä
(2 Arvostelua)

3 freelanceria on tarjonnut keskimäärin 110€ tähän työhön


Hi, I would like to work on this task and I will develop this in shell. I have five year of experience in this field. Please do let me know if we can discuss on this. Regards, Mayank

€160 EUR 4 päivässä
(1 arvostelu)

Greetings! I am very thankful for this chance because I have a similar kind of expertise and work experience. Let me introduce myself via the following. [login to view URL] Promise a high quality and on time. I would like Lisää

€120 EUR 7 päivässä
(0 arvostelua)