Public/Person/Get-PopuliPersonRoles.ps1
function Get-PopuliPersonRoles { [alias("Get-PopuliStudent")] [CmdletBinding(DefaultParametersetName='PersonId', PositionalBinding=$true)] param ( [Parameter(ParameterSetName='PersonId', Mandatory=$true)][string]$PersonId, [Parameter(Mandatory=$false)][ValidateLength(200,999)][string]$PopuliToken = $env:PopuliToken, [Parameter(Mandatory=$false)][ValidatePattern('^(?i)https:\/\/\S+\.populiweb\.com\/?$')][string]$BaseUrl = $env:PopuliBaseUrl ) try { if ($BaseUrl -match '\/$') { $BaseUrl = $BaseUrl -replace '\/$' } $header = @{ Authorization = $PopuliToken } $body = @{ task = 'getRoles' person_id = $PersonId } $response = Invoke-RestMethod -Uri "$BaseUrl/api/" -Method POST -ContentType 'application/x-www-form-urlencoded' -Body $body -Headers $header $person = $response.response Write-Log "Returning roles assigned to Person Id ""$PersonId""." return $person.response.role } catch { Write-Log "Error getting tags" -LogType: error -ErrorObject $_ Write-Error $_ return $null } } |