Adding, removing, or modifying AD users are the most common tasks of any Windows administrator. Having a well defined Powershell script makes this job much easier and consistent.
Okay, users my rough version of the new user:
# Description: Creates a new AD user in OU=Office Users,OU=Everett
Users,DC=Corp,DC=local Takes the like user and adds new user groups.
Converts plain text password to secure password.
#
# Created: 7-16-2018
write-host “Enter username”
read-host username
write-host “Enter Full Name”
read-host fullname
write-host “Enter password”
read-host password
write-host “Like user”
read-host likeuser
$newpassword = ConvertTo-SecureString $password -asplaintext -force
$groups = get-aduser $likeuser -properties memberof | select memberof
-expandproperties
$path = “OU=Office Users,OU=company Users,DC=company,DC=local”
new-aduser -samaccountname $username -path $path -Name $name –
accountpassword $newpassword
foreach ($i in $groups)
{ Add-AdGroupMember $i -members $username }
Another version on the web:
https://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=362
A newer version that has a very good explanation:
https://4sysops.com/archives/create-new-active-directory-users-with-a-powershell-script/
More to come…