Public/AdminRole/Get-MyGraphAdminRole.ps1

# Module: Orbit.Authentication
# Function: UserAdmin
# Author: David Eberhardt
# Updated: 01-SEP-2020
# Status: Live




function Get-MyGraphAdminRole {
  <#
  .SYNOPSIS
    Queries Admin Roles assigned to the currently connected User
  .DESCRIPTION
    Azure Active Directory Admin Roles assigned to the currently connected User
    Requires a Connection to Graph
  .PARAMETER Type
    Optional. Switches query to Active (Default) or Eligible Admin Roles
  .EXAMPLE
    Get-GraphAdminRole [-Type Active]
 
    Returns all active Admin Roles for the currently connected User
  .EXAMPLE
    Get-GraphAdminRole -Type Eligible
 
    Returns all eligible Admin Roles for the currently connected User
  .INPUTS
    System.String
  .OUTPUTS
    PSCustomObject
  .NOTES
    This is a wrapper for Get-GraphAdminRole targeting the currently connected User
  .COMPONENT
    UserAdmin
  .FUNCTIONALITY
    Queries active or eligible Privileged Identity roles for Administration of Teams for the currently connected User
  .LINK
    https://github.com/DEberhardt/Orbit/tree/main/docs/Orbit.Authentication/Get-MyGraphAdminRole.md
  .LINK
    https://github.com/DEberhardt/Orbit/tree/main/docs/about/about_UserManagement.md
  .LINK
    https://github.com/DEberhardt/Orbit/tree/main/docs/
  #>


  [CmdletBinding()]
  [Alias('gar')]
  [OutputType([PSCustomObject])]
  param(
    [Parameter(HelpMessage = 'Active, Eligible')]
    [ValidateSet('All', 'Active', 'Eligible')]
    #[ValidateSet('All', 'Active', 'Eligible','Group')]
    [string]$Type = 'All'

  ) #param

  begin {
    Show-OrbitFunctionStatus -Level Live
    Write-Verbose -Message "[BEGIN ] $($MyInvocation.MyCommand)"

    # Asserting Graph Connection
    if ( -not $script:TFPSSA) { $script:TFPSSA = Assert-GraphConnection; if ( -not $script:TFPSSA ) { break } }

    # Setting Preference Variables according to Upstream settings
    if (-not $PSBoundParameters['Verbose']) { $VerbosePreference = $PSCmdlet.SessionState.PSVariable.GetValue('VerbosePreference') }
    if (-not $PSBoundParameters['Confirm']) { $ConfirmPreference = $PSCmdlet.SessionState.PSVariable.GetValue('ConfirmPreference') }
    if (-not $PSBoundParameters['WhatIf']) { $WhatIfPreference = $PSCmdlet.SessionState.PSVariable.GetValue('WhatIfPreference') }
    $DebugPreference = if (-not $PSBoundParameters['Debug']) { $PSCmdlet.SessionState.PSVariable.GetValue('DebugPreference') } else { 'Continue' }
    $InformationPreference = if ( $PSBoundParameters['InformationAction']) { $PSCmdlet.SessionState.PSVariable.GetValue('InformationAction') } else { 'Continue' }

  } #begin

  process {
    Write-Verbose -Message "[PROCESS] $($MyInvocation.MyCommand)"

    Get-GraphAdminRole -Identity $(Get-MgContext).Account.Id -Type $Type

  } #process

  end {
    Write-Verbose -Message "[END ] $($MyInvocation.MyCommand)"
  } #end
} #Get-MyGraphAdminRole