-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCreate Students.ps1
More file actions
33 lines (28 loc) · 1015 Bytes
/
Copy pathCreate Students.ps1
File metadata and controls
33 lines (28 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Import the module
Import-Module -Name AeriesApi
# Set some variables
$URL = $args[0]
$Certificate = $args[1]
Initialize-AeriesApi -URL $URL -Certificate $Certificate
# Get all Students to Add
$Students = (Import-Csv -Path "C:\tmp\student.csv")
# Loop through the Students
foreach ($Student in $Students) {
# The values on the left are the command parameters
# The values on the right can be whatever you want, in this case mapping to CSV content
$StudentObject = @{
"FirstName" = $Student."First Name"
"LastName" = $Student."Last Name"
"Grade" = $Student."Grade Level"
}
try {
$NewStudent = (Add-AeriesStudent -SchoolCode $Student."School" @StudentObject)
Write-Host "Created Student ID $($NewStudent.StudentID) - $($NewStudent.FirstName) $($NewStudent.LastName)"
}
catch {
Write-Error "Error adding Student $($Student."First Name") $($Student."Last Name")`n$($Error[0])"
}
finally {
$NewStudent = $null
}
}