examples/Get-MSADir-Courses.ps1
Import-Module .\PSBlackboard.psm1 -Verbose -force #Import the CSV to an object $Header = 'course_id', 'username','EnrollmentType' $FeedFileInput = Import-Csv -Path ".\examples\temp\Get-MSADir-Courses-Input.csv" -Header $Header $FeedFileOutputLocation = ".\examples\temp\Get-MSADir-Courses-Output.csv" $FeedFileOutput = @() #Get all courses that match the name of the first field $FeedFileInput | ForEach-Object { $ExernalId = $_.course_id -split "-" $Filter = "ExternalId=$($ExernalId[1])-$($ExernalId[2])" $Matches = Get-BBCourses -Filter $Filter -Verbose foreach ($Match in $Matches) { $FeedFileOutput += [PSCUstomObject]@{ course_id = $Match.courseId username = $_.username EnrollmentType = $_.EnrollmentType } } } $FeedFileOutput | Sort-Object -Property course_id | ConvertTo-Csv -NoTypeInformation | % { $_ -replace '"', ""} | select-object -Skip 1 |Set-Content -path $FeedFileOutputLocation |