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 Write-Log "Returning roles assigned to Person Id ""$PersonId"" -- $($response.response.role.name -join ', ')" -PersonId $PersonId return $response.response.role } catch { Write-Log "Error getting tags" -LogType: error -ErrorObject $_ -PersonId $PersonId Write-Error $_ return $null } } |