Add working code and new CSV file with modifications
This commit is contained in:
parent
974c442ad8
commit
c374c56046
|
@ -1,8 +1,8 @@
|
||||||
# Copyright 2024 Rayyan Hodges, M Salim Olime, TAFE NSW, AlphaDelta
|
# Copyright 2024 Rayyan Hodges, M Salim Olime, TAFE NSW, AlphaDelta
|
||||||
# Contact: rayyan.hodges@studytafensw.edu.au
|
# Contact: rayyan.hodges@studytafensw.edu.au, mohammad.olime1@tafensw.edu.au
|
||||||
# Program Name: AutoUserCreator
|
# Program Name: AutoUserAndOUCreator
|
||||||
# Purpose of script: Create a batch set of user's using a CSV file containing a list of predetermined users.
|
# Purpose of script: Create a batch set of user's using a CSV file containing a list of predetermined users.
|
||||||
#Other notes: Orginally created by M Salim Olime, my teacher as part of our class with my assigned modification of creating batch OU's within the script.
|
# Other notes: Orginally created by M Salim Olime (Salim), my teacher as part of our class with my assigned modification of creating batch OU's within the script.
|
||||||
|
|
||||||
# Import required PowerShell modules
|
# Import required PowerShell modules
|
||||||
import-module ActiveDirectory
|
import-module ActiveDirectory
|
||||||
|
@ -15,6 +15,12 @@ $fusers = Import-Csv $fpath
|
||||||
#Set tempoary password to "Pa$$w0rd1" which the user will be required to change when they first login.
|
#Set tempoary password to "Pa$$w0rd1" which the user will be required to change when they first login.
|
||||||
$fsecPass = ConvertTo-SecureString -AsPlainText "Pa$$w0rd1" -Force
|
$fsecPass = ConvertTo-SecureString -AsPlainText "Pa$$w0rd1" -Force
|
||||||
|
|
||||||
|
# Create OU's to be placed in Active Directory (My contribution)
|
||||||
|
foreach ($ou in $fous) {
|
||||||
|
$name = $ou.OuName
|
||||||
|
$path = $ou.OuPath
|
||||||
|
New-ADOrganizationalUnit -Name $name -Path $path
|
||||||
|
}
|
||||||
|
|
||||||
# Create user within already created OU
|
# Create user within already created OU
|
||||||
ForEach ($user in $fusers) {
|
ForEach ($user in $fusers) {
|
||||||
|
@ -24,4 +30,4 @@ ForEach ($user in $fusers) {
|
||||||
$OUpath = $user.OU
|
$OUpath = $user.OU
|
||||||
echo $fname $lname $jtitle $OUpath
|
echo $fname $lname $jtitle $OUpath
|
||||||
New-ADUser -SamAccountName = $fname.$lname -UserPrincipalName "$fname@alphadelta.com" -Path $OUpath -AccountPassword $fsecPass -Enabled $true -PassThru
|
New-ADUser -SamAccountName = $fname.$lname -UserPrincipalName "$fname@alphadelta.com" -Path $OUpath -AccountPassword $fsecPass -Enabled $true -PassThru
|
||||||
}
|
}
|
24
UserList.csv
24
UserList.csv
|
@ -1,12 +1,12 @@
|
||||||
fName,lName,jTitle,OuName
|
fName,lName,jTitle,OuName,OuPath
|
||||||
Mary,Stolle,CEO,"ou=CEOOu,dc=alphadelta,dc=com"
|
Mary,Stolle,CEO,CEOOu,"dc=alphadelta,dc=com"
|
||||||
Syed,Acharya,Finance,"ou=FinanceOu,dc=alphadelta,dc=com"
|
Syed,Acharya,Finance,FinanceOu,"dc=alphadelta,dc=com"
|
||||||
Johannes,Klein,Sales,"ou=SalesOu,dc=alphadelta,dc=com"
|
Johannes,Klein,Sales,SalesOu,"dc=alphadelta,dc=com"
|
||||||
David,Jones,Purchasing,"ou=PurchasingOu,dc=alphadelta,dc=com"
|
David,Jones,Purchasing,PurchasingOu,"dc=alphadelta,dc=com"
|
||||||
Seamus,O'Grady,HR,"ou=HROu,dc=alphadelta,dc=com"
|
Seamus,O'Grady,HR,HROu,"dc=alphadelta,dc=com"
|
||||||
Susan,Ng,Employee,"ou=StaffOu,dc=alphadelta,dc=com"
|
Susan,Ng,Employee,StaffOu,"dc=alphadelta,dc=com"
|
||||||
Samuel,Lee,IT,"ou=ITOu,dc=alphadelta,dc=com"
|
Samuel,Lee,IT,ITOu,"dc=alphadelta,dc=com"
|
||||||
Tom,Chung,Employee,"ou=StaffOu,dc=alphadelta,dc=com"
|
Tom,Chung,Employee,StaffOu,"dc=alphadelta,dc=com"
|
||||||
Wei,Yoon,Employee,"ou=StaffOu,dc=alphadelta,dc=com"
|
Wei,Yoon,Employee,StaffOu,"dc=alphadelta,dc=com"
|
||||||
Mercedes,Schmidt,Employee,"ou=StaffOu,dc=alphadelta,dc=com"
|
Mercedes,Schmidt,Employee,StaffOu,"dc=alphadelta,dc=com"
|
||||||
Rayyan,Hodges,Employee,"ou=StaffOu,dc=alphadelta,dc=com"
|
Rayyan,Hodges,Employee,StaffOu,"dc=alphadelta,dc=com"
|
||||||
|
|
|
Loading…
Reference in New Issue