commit daa01e0966d536a48773b26cbf2f7d33c5c46c56 Author: reiyua Date: Mon Mar 25 22:02:11 2024 +1100 Create AutoUserCreator.ps1 diff --git a/AutoUserCreator.ps1 b/AutoUserCreator.ps1 new file mode 100644 index 0000000..da4eb24 --- /dev/null +++ b/AutoUserCreator.ps1 @@ -0,0 +1,27 @@ +# Copyright 2024 Rayyan Hodges, TAFE NSW, AlphaDelta +# Contact: rayyan.hodges@studytafensw.edu.au +# Program Name: AutoUserCreator +# Purpose of script: Create a batch set of user's using a CSV file containing a list of predetermined users. + +# Import required PowerShell Modules +Import-Module ActiveDirectory + +# Define temporary password which MUST be changed when the user first logs into the Active Directory. +$SecurePass = ConvertTo-SecureString -AsPlainText "Mypassword1" -Force + +# Force user to change password when logging on for the first time +ChangePasswordAtLogon = $true + +# Define the file path where the CSV file containing users is. +$csvfilepath = Read-Host - Prompt "Please enter the location of the CSV file containing the user list" + +# Define variables for various columns within CSV file. +ForEach ($user in $users) { +$fname = $user.'First Name’ +$lname = $user.'Last Name' +$jtitle = $user.'Job Title' +$OUpath = $user.'Organizational Unit' + +# Command to add user's to Active Directory. +New-ADUser -Name $fname -UserPrincipalName "$fname.$lname" +}