I need to write a Powershell script to perform the following steps.
1. Pull user information from two separate tables in a SQL database (database1)
a. Pull FirstName, LastName, Nickname, and GovernmentID fields from Table1
b. Pull LastTerm and CampusName from Table2
Note: Table1 and Table2 are related via an EmployeeID field that is the PK in both tables
2. Create new AD username by concatenating the "FirstName" + "." + "LastName" fields.
3. Create new AD passwords for each user by concatenating the first 4 characters of "FirstName" + "." + "LastName" + "." + "GovernmentID".
1. Only create accounts if an account with the same username does not already exist in AD.
2. Only create accounts if the LastTerm field is less than 1 year ago (measured in standard years)
3. If two accounts exist in SQL that have the same FirstName.LastName, but different EmployeeID's, I need to substitute the Nickname for the FirstName in both username and password generators, using the same First 4 rule in the password
4. Create each account in an OU that bears the name of the CampusName field
What would a template for this type of script look like?