How to build an AD App for Onboarding Users

Management of Active Directory users within organizations could be a full-time occupation. Any automation skill is welcomed, as technology support specialists are so versatile.
The most tedious task when creating new users in Active Directory Users & Computers is to add all the necessary settings and properties to user accounts. This can be a tedious process depending on how many users you want to add and how complex your environment is.
Leveraging PowerShell, let us look at a simple script you can use to provide a framework for your team. It can be used as-is, but can also be easily customized to your domain’s requirements when it comes time to onboard new Active Directory users. This article will use the script provided on GitHub.
Create the Script Interface
This sub-heading should not be a deterrent. This interface will be very simple and will prompt you for the information that you need to create your user account. The script that is used in this article will ask for your first and last names as separate inputs. A simple numbered list will then show you the various departments in your organization. Just select the number of the department and hit enter. The script will take care of the rest!
Learn how to become a security expert with SPOTO’s Cybersecurity Training
Start training
User first name
User last name
Department (represented by a number).
$UserFirstname = On-Host “Enter first name of user you wish to Onboard.”
$UserLastname =Read-Host “Enter last name of user you wish to Onboard.”
Write-Host –foregroundcolor Yellow “What Department will this user be in?”
Write-host -foregroundcolor Gray ”
1> Manufacturing 2> Accounting
3> Department C 4> Dept D
5> Department E
$Department = Read -Host “Enter #”
This will create the interface as such.

It is constructed using Read-Host cmdlets, and a quick and dirty menu of various departments. The switch statement is used to distinguish departments. Microsoft Docs provides information about the switch statement.
The $Department variable can be set with the ReadHost statement asking for department #:
{Switch ($Department)Switch ($Department).
1 $Department = “Manufacturing”
2 $Department = “Accounting”
3 $Department = “Department C”
4 $Department = “Department D”
5 $Department = “Department E”
If your username convention is firstname.lastname you can create the username and the home directory path. The.ToLower() option will make all letters in your username lowercase no matter how you entered them. The following will set your username and home drive path.
$SAMAccountName = (“$UserFirstname” + “.” + “$UserLastname”).ToLower()
$HomeDrivePath = “\\fs01\users\” + “$SAMAccountName”
Build the User Object
It is a good practice to create every user account exactly the same way every time. This script does exactly that right from the beginning. This script should contain the most common settings and properties that all domain users need. After the base account has been created, the distinct properties, settings, configurations are then branched according to the department input.
Once you have set the variables, you can create the account with these parameters:
Places the account at a “generic location”. The account must be created somewhere. It’s created in a general OU. The switch statement blocks will move the account to the location it needs.
This sets the password to a temporary (temporary) password and forces a change upon first login
Sets the names (SAMaccount and display name, etc.