Kaffeeundcode
Script Library
PowerShell 01.06.2026

Script Workspace

Get GraphTokenDetails

Review the purpose, inspect the code, then test it safely in your own tenant.

82_Get-GraphTokenDetails.ps1

<#
.SYNOPSIS
    Zeigt Details zum aktuellen Access Token.
    
.DESCRIPTION
    Listet Scopes (Berechtigungen) und Ablaufdatum des aktuellen Tickets auf.
    Erfordert keine spezielle Berechtigung (lokaler Kontext).

.NOTES
    File Name: 82_Get-GraphTokenDetails.ps1
    Author: Mattia Cirillo
    Version: 1.0
#>

param()

$Context = Get-MgContext
if ($Context) {
    Write-Host "Account: $($Context.Account)"
    Write-Host "Scopes: $($Context.Scopes -join ', ')"
    # Token expiration usually not exposed directly in basic Get-MgContext output object in all versions, but scopes are key.
} else {
    Write-Warning "Nicht verbunden."
}