functions/Set-BBUserToStudent.ps1
#Import Useful Modules #Import-Module .\PSBlackboard.psm1 -Verbose -force <# .Synopsis Sets a user in the Blackboard Learn Environment to be a student. .DESCRIPTION Sets a user in the Blackboard Learn Environment to be a student. Clears out any addional Institution Roles and system roles. Sets them To Student and User, Respectivly. .EXAMPLE Set-BBUserToStudent -GlobalId 'schal1r' -environment test #> function Set-BBUserToStudent { [CmdletBinding()] [Alias()] Param ( [string]$GlobalID, [string]$Environment = 'Production' ) Begin { } Process { #Get the BBUser $BBUserRecords = Get-BBUsers -ExternalID $GlobalID -Environment $Environment $UntouchedRecords = $BBUserRecords #Remove all system roles that are not student foreach ($BBUserRecord in $BBUserRecords) { $BBUserRecord.institutionRoleIds = @('STUDENT') $BBUserRecord.systemRoleIds = @('User') } #Set the BBUser $UpdatedUsers += $BBUserRecords | Set-BBUser -environment $Environment -verbose } End { if($UntouchedRecords -eq $BBUserRecords){ return $null }else{ $UntouchedRecords } } } |