Automation Active Directory (create a new user)
LETS START WITH SOME BASICS, WE ALL NEED THE BASICS FOR ANY USER.
Username
Title
GivenName (First Name)
SurName (Last Name)
Password
WE WILL ASSIGN EACH TO A VARIABLE. (PASSWORD IS IN CLEAR-TEXT)
$Username = 'BBunny'
$Title = 'Carrot Manager'
$FirstName = 'Bugs'
$LastName = 'Bunny'
$Password = 'p@$$word1'
WE WILL CREATE THIA AS A FUNCTION TO START USING THE WORD CALLED "AUTOMATION" TO MAKE LIVES EASIER.
$Parameters = @{
'Name' = $Username
'Title' = $Title
'GivenName' = $FirstName
'SurName' = $LastName
'Password' = (ConvertTo-SecureString $Password -AsPlainText -Force)
}
New-AdUser @Parameters
WE WILL CREATE A NEW TEXT FILE AND RENAME IT TO NEWUSER.PS1 THIS WILL BE A POWERSHELL SCRIPT.
######################
# Create New User Script
######################
param($Username, $Title, $FirstName, $LastName, $Password)
$Parameters = @{
'Name' = $Username
'Title' = $Title
'GivenName' = $FirstName
'SurName' = $LastName
'Password' = (ConvertTo-SecureString $Password -AsPlainText -Force)
}
New-AdUser @Parameters
######################
# Send email to user
######################
Send-MailMessage -To "Bugs Bunny <$Username@example.com>" -From "IT Department" -Subject 'Your AD account has been setup'
######################
# Send email to admin
######################
Send-MailMessage -To "IT Department" -From "IT Department " -Subject 'AD account for $Username, has been created with the following information:
Name: $FirstName $LastName
Title: $Title
Username: $Username'
HOW TO RUN THE SCRIPT TO AUTOMATE THE PROCESS.
PS> Create-NewUser.ps1 -Name DDuck -Title 'Comedy Manager' -FirstName 'Daffy' -LastName 'DDuck' -Password 'p@$$word1'
LETS START WITH SOME BASICS, WE ALL NEED THE BASICS FOR ANY USER.
Username
Title
GivenName (First Name)
SurName (Last Name)
Password
WE WILL ASSIGN EACH TO A VARIABLE. (PASSWORD IS IN CLEAR-TEXT)
$Username = 'BBunny'
$Title = 'Carrot Manager'
$FirstName = 'Bugs'
$LastName = 'Bunny'
$Password = 'p@$$word1'
WE WILL CREATE THIA AS A FUNCTION TO START USING THE WORD CALLED "AUTOMATION" TO MAKE LIVES EASIER.
$Parameters = @{
'Name' = $Username
'Title' = $Title
'GivenName' = $FirstName
'SurName' = $LastName
'Password' = (ConvertTo-SecureString $Password -AsPlainText -Force)
}
New-AdUser @Parameters
WE WILL CREATE A NEW TEXT FILE AND RENAME IT TO NEWUSER.PS1 THIS WILL BE A POWERSHELL SCRIPT.
######################
# Create New User Script
######################
param($Username, $Title, $FirstName, $LastName, $Password)
$Parameters = @{
'Name' = $Username
'Title' = $Title
'GivenName' = $FirstName
'SurName' = $LastName
'Password' = (ConvertTo-SecureString $Password -AsPlainText -Force)
}
New-AdUser @Parameters
######################
# Send email to user
######################
Send-MailMessage -To "Bugs Bunny <$Username@example.com>" -From "IT Department
######################
# Send email to admin
######################
Send-MailMessage -To "IT Department
Name: $FirstName $LastName
Title: $Title
Username: $Username'
HOW TO RUN THE SCRIPT TO AUTOMATE THE PROCESS.
PS> Create-NewUser.ps1 -Name DDuck -Title 'Comedy Manager' -FirstName 'Daffy' -LastName 'DDuck' -Password 'p@$$word1'