Collect audit data by sis_course_id Powershell

stephen_taylor
Community Contributor

Hi everyone, 

I'm still wrapping my head around using powershell and APIs I've managed to set up this

for ( $i_p = 1 ; $i_p -lt 44 ; $i_p += 1 ){
$courses = ((Invoke-WebRequest -Headers $headers -Uri "$uri/accounts/1/courses?include[]=teachers&per_page=100&sort=sis_course_id&page=$i_p").content )| convertfrom-json | Where {($courses.name -inotlike "*Template*" -and $courses.name -inotlike "*Sandbox")}
Foreach ($course in $courses) {
$teachername = $course | Select-Object -ExpandProperty teachers

$coursesdata = $courses | Select-Object -Property Name, sis_course_id, id,
@{ label = "Teacher"; expression = {$teachername.display_name} }
$coursesdata | Format-List}
}

Which returns a nicely formatted list of Course names, SIS ID's, ID's and Teacher Names for me, but I want to add in an Audit api so I can tell if a course has been worked on.

I know I need to run 

 $c_audit = ((Invoke-WebRequest -Headers $headers -Uri  "$uri/audit/course/courses/$_.json").content | convertfrom-json)

     $n_audit = ($c_audit.events).count

But I can;t figure out how to get the $courses.id to insert into the formula, or how to make it list the resultant event count in the same order I have collected the $coursedata.   

Does anyone have any ideas?

Labels (1)
0 Likes