{"id":123,"date":"2026-03-13T09:22:09","date_gmt":"2026-03-13T09:22:09","guid":{"rendered":"https:\/\/unen.nl\/?p=123"},"modified":"2026-03-13T09:23:11","modified_gmt":"2026-03-13T09:23:11","slug":"powershell-tijdelijke-toegang-zonder-gedoe-temporary-access-pass-automatiseren","status":"publish","type":"post","link":"https:\/\/unen.nl\/?p=123","title":{"rendered":"Powershell : Tijdelijke toegang zonder gedoe: Temporary Access Pass automatiseren"},"content":{"rendered":"\n<p>Iedere beheerder kent het wel.<\/p>\n\n\n\n<p>Een gebruiker kan niet meer inloggen omdat:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>de telefoon met Microsoft Authenticator verdwenen is \ud83d\udcf1<\/li>\n\n\n\n<li>MFA opnieuw ingesteld moet worden<\/li>\n\n\n\n<li>een nieuwe medewerker nog geen MFA heeft ingesteld<\/li>\n<\/ul>\n\n\n\n<p>Dan begint vaak het bekende proces van <strong>MFA resetten of tijdelijke toegang regelen<\/strong>.<\/p>\n\n\n\n<p>Gelukkig heeft Microsoft hiervoor een uitstekende oplossing: <strong>Temporary Access Pass (TAP)<\/strong>.<\/p>\n\n\n\n<p>Met een TAP kan een gebruiker tijdelijk inloggen en bijvoorbeeld MFA opnieuw instellen. Maar als beheerder wil je dit natuurlijk <strong>consistent, veilig en geautomatiseerd<\/strong> configureren.<\/p>\n\n\n\n<p>Daarom heb ik een <strong>PowerShell script gemaakt dat de TAP-policy automatisch configureert via Microsoft Graph<\/strong>.<\/p>\n\n\n\n<p>Inclusief:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>automatische installatie van Microsoft Graph<\/li>\n\n\n\n<li>parametercontrole<\/li>\n\n\n\n<li>logging<\/li>\n\n\n\n<li>transcript logging voor Intune<\/li>\n\n\n\n<li>verificatie van de configuratie<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">Wat is een Temporary Access Pass?<\/h1>\n\n\n\n<p>Een <strong>Temporary Access Pass<\/strong> is een tijdelijke toegangscode binnen <strong>Microsoft Entra ID<\/strong> waarmee een gebruiker kan:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>MFA opnieuw registreren<\/li>\n\n\n\n<li>een nieuwe authenticator-app instellen<\/li>\n\n\n\n<li>toegang krijgen tot het account zonder bestaande MFA<\/li>\n\n\n\n<li>een nieuw apparaat configureren<\/li>\n<\/ul>\n\n\n\n<p>Je kunt het zien als een <strong>tijdelijke sleutel tot de voordeur van een account<\/strong>.<\/p>\n\n\n\n<p>De TAP is bewust tijdelijk en kan worden ingesteld met:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>een minimale geldigheid<\/li>\n\n\n\n<li>een maximale geldigheid<\/li>\n\n\n\n<li>een code lengte<\/li>\n\n\n\n<li>eenmalig gebruik<\/li>\n<\/ul>\n\n\n\n<p>Juist deze instellingen bepalen <strong>hoe veilig en gebruiksvriendelijk je omgeving is<\/strong>.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">TAP + MFA flow<\/h1>\n\n\n\n<p>Onderstaand diagram laat zien hoe TAP werkt in combinatie met MFA.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"http:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-13-2026-10_18_38-AM-1024x683.png\" alt=\"\" class=\"wp-image-127\" srcset=\"https:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-13-2026-10_18_38-AM-1024x683.png 1024w, https:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-13-2026-10_18_38-AM-300x200.png 300w, https:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-13-2026-10_18_38-AM-768x512.png 768w, https:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/ChatGPT-Image-Mar-13-2026-10_18_38-AM.png 1536w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Flow uitgelegd<\/h3>\n\n\n\n<p>1\ufe0f\u20e3 Beheerder maakt een Temporary Access Pass<br>2\ufe0f\u20e3 De gebruiker ontvangt de tijdelijke code<br>3\ufe0f\u20e3 Gebruiker logt in met TAP<br>4\ufe0f\u20e3 Microsoft Entra valideert de code<br>5\ufe0f\u20e3 MFA registratie wordt gestart<br>6\ufe0f\u20e3 TAP wordt ongeldig<\/p>\n\n\n\n<p>Na deze stappen gebruikt de gebruiker weer <strong>normale MFA authenticatie<\/strong>.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Verbinding maken met Microsoft Graph<\/h1>\n\n\n\n<p>Het script gebruikt Microsoft Graph om de TAP-policy te wijzigen.<\/p>\n\n\n\n<p>Dit gebeurt met:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Connect-MgGraph -Scopes \"Policy.ReadWrite.AuthenticationMethod\"<\/pre>\n\n\n\n<p>Wanneer het script voor het eerst wordt uitgevoerd, verschijnt er een <strong>Microsoft loginvenster<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Microsoft login scherm<\/h3>\n\n\n\n<p>Hier log je in met een account dat voldoende rechten heeft.<\/p>\n\n\n\n<p>Bijvoorbeeld:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Global Administrator<\/li>\n\n\n\n<li>Authentication Administrator<\/li>\n\n\n\n<li>Privileged Authentication Administrator<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"564\" height=\"454\" src=\"http:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/Connect-mggraph-1.png\" alt=\"\" class=\"wp-image-120\" srcset=\"https:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/Connect-mggraph-1.png 564w, https:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/Connect-mggraph-1-300x241.png 300w\" sizes=\"auto, (max-width: 564px) 100vw, 564px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">Toestemming geven aan Microsoft Graph<\/h1>\n\n\n\n<p>Omdat het script policies wijzigt, moet Microsoft Graph toestemming krijgen.<\/p>\n\n\n\n<p>Het belangrijkste recht is:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Policy.ReadWrite.AuthenticationMethod<\/pre>\n\n\n\n<p>Dit geeft toegang tot <strong>authentication method policies<\/strong>, waaronder Temporary Access Pass.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"562\" height=\"509\" src=\"http:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/Connect-mggraph-2.png\" alt=\"\" class=\"wp-image-121\" srcset=\"https:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/Connect-mggraph-2.png 562w, https:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/Connect-mggraph-2-300x272.png 300w\" sizes=\"auto, (max-width: 562px) 100vw, 562px\" \/><\/figure>\n\n\n\n<p>Door op <strong>Accept<\/strong> te klikken krijgt de Microsoft Graph module toegang.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Overzicht van rechten<\/h1>\n\n\n\n<p>Microsoft Graph toont een lijst met rechten die gebruikt kunnen worden.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"567\" height=\"749\" src=\"http:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/Connect-mggraph-3.png\" alt=\"\" class=\"wp-image-122\" srcset=\"https:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/Connect-mggraph-3.png 567w, https:\/\/unen.nl\/wp-content\/uploads\/2026\/03\/Connect-mggraph-3-227x300.png 227w\" sizes=\"auto, (max-width: 567px) 100vw, 567px\" \/><\/figure>\n\n\n\n<p>Dit lijkt een lange lijst, maar deze rechten horen bij de <strong>Microsoft Graph Command Line Tools<\/strong>.<\/p>\n\n\n\n<p>Het script zelf gebruikt alleen:<\/p>\n\n\n\n<p><strong>Authentication Method Policy management<\/strong><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Waarom deze TAP instellingen?<\/h1>\n\n\n\n<p>In het script gebruik ik de volgende instellingen.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Default lifetime \u2013 30 minuten<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">DefaultLifetimeInMinutes = 30<\/pre>\n\n\n\n<p>Dit betekent dat een TAP standaard <strong>30 minuten geldig is<\/strong>.<\/p>\n\n\n\n<p>Lang genoeg voor een gebruiker om:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>de code te ontvangen<\/li>\n\n\n\n<li>in te loggen<\/li>\n\n\n\n<li>MFA te registreren<\/li>\n<\/ul>\n\n\n\n<p>Maar kort genoeg om risico te beperken.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Minimum lifetime \u2013 10 minuten<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">MinimumLifetimeInMinutes = 10<\/pre>\n\n\n\n<p>Dit voorkomt dat iemand per ongeluk een TAP maakt die <strong>bijna direct verloopt<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Maximum lifetime \u2013 60 minuten<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">MaximumLifetimeInMinutes = 60<\/pre>\n\n\n\n<p>Hiermee voorkom je dat TAP codes <strong>uren of dagen geldig blijven<\/strong>.<\/p>\n\n\n\n<p>Een TAP moet tijdelijk blijven.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">TAP lengte \u2013 14 tekens<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">TapLength = 14<\/pre>\n\n\n\n<p>Dit geeft een goede balans tussen:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>veiligheid<\/li>\n\n\n\n<li>entropie<\/li>\n\n\n\n<li>gebruiksgemak<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">E\u00e9nmalig gebruik<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">UsableOnce = $true<\/pre>\n\n\n\n<p>Dit is een belangrijke beveiligingsmaatregel.<\/p>\n\n\n\n<p>Na gebruik is de TAP <strong>direct ongeldig<\/strong>.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Security best practices voor TAP<\/h1>\n\n\n\n<p>Een paar praktische adviezen die ik zelf vaak gebruik in tenants.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Gebruik altijd &#8220;usable once&#8221;<\/h3>\n\n\n\n<p>Een TAP moet <strong>maar \u00e9\u00e9n keer gebruikt kunnen worden<\/strong>.<\/p>\n\n\n\n<p>Dit voorkomt hergebruik van de code.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Houd de geldigheid kort<\/h3>\n\n\n\n<p>Aanbevolen waarden:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Default: 30 minuten<br>Maximum: 60 minuten<\/pre>\n\n\n\n<p>Hoe korter de geldigheid, hoe kleiner het risico.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Gebruik Conditional Access<\/h3>\n\n\n\n<p>Combineer TAP met:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Conditional Access<\/li>\n\n\n\n<li>MFA registratie policies<\/li>\n\n\n\n<li>Identity Protection<\/li>\n<\/ul>\n\n\n\n<p>Zo blijft TAP veilig.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Beperk wie TAP mag genereren<\/h3>\n\n\n\n<p>Gebruik alleen rollen zoals:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Authentication Administrator<\/li>\n\n\n\n<li>Privileged Authentication Administrator<\/li>\n<\/ul>\n\n\n\n<p>Zo voorkom je dat te veel mensen tijdelijke toegang kunnen genereren.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Logging en troubleshooting<\/h1>\n\n\n\n<p>Het script schrijft logs naar:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">C:\\Log<\/pre>\n\n\n\n<p>Hier wordt onder andere opgeslagen:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>script versie<\/li>\n\n\n\n<li>gebruiker<\/li>\n\n\n\n<li>apparaat<\/li>\n\n\n\n<li>IP adres<\/li>\n\n\n\n<li>TAP configuratie<\/li>\n<\/ul>\n\n\n\n<p>Daarnaast wordt het transcript gekopieerd naar:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">C:\\ProgramData\\Microsoft\\IntuneManagementExtension\\Logs<\/pre>\n\n\n\n<p>Hierdoor kun je het script ook gebruiken binnen <strong>Intune of automatisering<\/strong>.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Het PowerShell script<\/h1>\n\n\n\n<p>Hieronder staat het volledige script dat de TAP-policy configureert.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">param (<br>    [switch]$Silent,<br>    [int]$DefaultLifetimeInMinutes = 30,<br>    [int]$MinimumLifetimeInMinutes = 10,<br>    [int]$MaximumLifetimeInMinutes = 60,<br>    [int]$TapLength = 14,<br>    [bool]$UsableOnce = $true<br>)<br><br>&lt;#<br>    .NOTES<br>    ===============================================================================<br>    Created on:    2026-03-13<br>    Created by:    Vincent van Unen<br>    Organization:  <br>    Filename:      Set-TAPPolicy-v2.ps1<br>    ===============================================================================<br><br>    .DESCRIPTION<br>    Wijzigt de Temporary Access Pass-configuratie binnen Microsoft Entra ID<br>    via Microsoft Graph. Indien Microsoft Graph nog niet is ge\u00efnstalleerd,<br>    wordt deze automatisch ge\u00efnstalleerd voor de huidige gebruiker.<br><br>    .VERSION<br>    1.4.0<br>#><br><br>#region Script metadata<br>$ScriptAuthor        = \"Vincent van Unen\"<br>$ScriptVersion       = \"1.4.0\"<br>$ScriptChangeDate    = \"2026-03-13\"<br>$ScriptChangeLog     = \"Toegevoegd: controle en automatische installatie van Microsoft.Graph, parameterisering van TAP-instellingen\"<br>$ScriptCurrentUser   = $env:USERNAME<br>$ScriptRunningDevice = $env:COMPUTERNAME<br>$CurrentDate         = Get-Date -Format 'yyyy-MM-dd'<br>$ScriptName          = \"Set-TAPPolicy-v2\"<br>#endregion Script metadata<br><br>#region Paths<br>$TempPaths = @(<br>    \"C:\\Temp\",<br>    \"C:\\Tmp\",<br>    \"C:\\Log\"<br>)<br><br>foreach ($Path in $TempPaths) {<br>    if (-not (Test-Path -Path $Path)) {<br>        New-Item -ItemType Directory -Path $Path -Force | Out-Null<br>    }<br>}<br><br>$LogDirectory   = \"C:\\Log\"<br>$LogFile        = Join-Path $LogDirectory \"$ScriptName-$CurrentDate.log\"<br>$TranscriptFile = Join-Path $LogDirectory \"$ScriptName-$CurrentDate-Transcript.log\"<br>$IntuneLogPath  = \"C:\\ProgramData\\Microsoft\\IntuneManagementExtension\\Logs\"<br>#endregion Paths<br><br>#region Logging<br>function Write-ToLogFile {<br>    [CmdletBinding()]<br>    param (<br>        [Parameter(Mandatory = $false)]<br>        [ValidateSet(\"INFO\", \"WARN\", \"ERROR\", \"FATAL\", \"DEBUG\")]<br>        [string]$Level = \"INFO\",<br><br>        [Parameter(Mandatory = $true)]<br>        [string]$Message,<br><br>        [Parameter(Mandatory = $false)]<br>        [string]$FilePath = $LogFile<br>    )<br><br>    try {<br>        if ([string]::IsNullOrWhiteSpace($Message)) {<br>            Add-Content -Path $FilePath -Value \"\" -ErrorAction Stop<br>        }<br>        else {<br>            $Date = (Get-Date).ToString('yyyy-MM-dd HH:mm:ss.fff')<br>            Add-Content -Path $FilePath -Value \"[$Date] [$Level] $Message\" -ErrorAction Stop<br>        }<br>    }<br>    catch {<br>        Write-Warning \"Schrijven naar logbestand is mislukt: $($_.Exception.Message)\"<br>    }<br>}<br>#endregion Logging<br><br>#region Helper functions<br>function Get-PublicIP {<br>    [CmdletBinding()]<br>    param ()<br><br>    try {<br>        return (Invoke-RestMethod -Uri \"https:\/\/ifconfig.me\/ip\" -ErrorAction Stop).Trim()<br>    }<br>    catch {<br>        Write-ToLogFile -Level \"WARN\" -Message \"Publiek IP-adres kon niet worden opgehaald: $($_.Exception.Message)\"<br>        return \"Onbekend\"<br>    }<br>}<br><br>function Get-PrivateIP {<br>    [CmdletBinding()]<br>    param ()<br><br>    try {<br>        $IpAddress = Get-NetIPAddress -AddressFamily IPv4 -ErrorAction Stop |<br>            Where-Object {<br>                $_.IPAddress -notlike '169.254*' -and<br>                $_.IPAddress -ne '127.0.0.1'<br>            } |<br>            Select-Object -ExpandProperty IPAddress -First 1<br><br>        if ([string]::IsNullOrWhiteSpace($IpAddress)) {<br>            return \"Onbekend\"<br>        }<br><br>        return $IpAddress<br>    }<br>    catch {<br>        Write-ToLogFile -Level \"WARN\" -Message \"Priv\u00e9 IP-adres kon niet worden opgehaald: $($_.Exception.Message)\"<br>        return \"Onbekend\"<br>    }<br>}<br><br>function Install-MicrosoftGraphModule {<br>    [CmdletBinding()]<br>    param ()<br><br>    try {<br>        $ModuleExists = Get-Module -ListAvailable -Name Microsoft.Graph<br><br>        if (-not $ModuleExists) {<br>            Write-ToLogFile -Message \"Microsoft.Graph module niet gevonden. Installatie wordt gestart.\"<br><br>            if (-not (Get-PackageProvider -Name NuGet -ErrorAction SilentlyContinue)) {<br>                Write-ToLogFile -Message \"NuGet package provider niet gevonden. Installatie wordt gestart.\"<br>                Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -ErrorAction Stop<br>            }<br><br>            $PsGallery = Get-PSRepository -Name PSGallery -ErrorAction SilentlyContinue<br>            if ($PsGallery -and $PsGallery.InstallationPolicy -ne 'Trusted') {<br>                Write-ToLogFile -Message \"PSGallery wordt op Trusted gezet.\"<br>                Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -ErrorAction Stop<br>            }<br><br>            Install-Module Microsoft.Graph -Scope CurrentUser -Force -AllowClobber -ErrorAction Stop<br>            Write-ToLogFile -Message \"Microsoft.Graph module succesvol ge\u00efnstalleerd.\"<br>        }<br>        else {<br>            Write-ToLogFile -Message \"Microsoft.Graph module is al aanwezig.\"<br>        }<br><br>        Import-Module Microsoft.Graph.Authentication -ErrorAction Stop<br>        Write-ToLogFile -Message \"Microsoft.Graph.Authentication module succesvol geladen.\"<br>    }<br>    catch {<br>        Write-ToLogFile -Level \"ERROR\" -Message \"Installatie of import van Microsoft.Graph is mislukt: $($_.Exception.Message)\"<br>        throw<br>    }<br>}<br><br>function Test-TapParameters {<br>    [CmdletBinding()]<br>    param ()<br><br>    if ($MinimumLifetimeInMinutes -gt $DefaultLifetimeInMinutes) {<br>        throw \"MinimumLifetimeInMinutes mag niet groter zijn dan DefaultLifetimeInMinutes.\"<br>    }<br><br>    if ($MaximumLifetimeInMinutes -lt $DefaultLifetimeInMinutes) {<br>        throw \"MaximumLifetimeInMinutes mag niet kleiner zijn dan DefaultLifetimeInMinutes.\"<br>    }<br><br>    if ($TapLength -lt 8 -or $TapLength -gt 48) {<br>        throw \"TapLength moet tussen 8 en 48 liggen.\"<br>    }<br><br>    if ($MinimumLifetimeInMinutes -lt 10) {<br>        throw \"MinimumLifetimeInMinutes moet minimaal 10 zijn.\"<br>    }<br>}<br>#endregion Helper functions<br><br>#region Script start<br>$PublicIP  = Get-PublicIP<br>$PrivateIP = Get-PrivateIP<br><br>Write-ToLogFile -Message \"Huidige datum = $CurrentDate\"<br>Write-ToLogFile -Message \"Script auteur = $ScriptAuthor\"<br>Write-ToLogFile -Message \"Script versie = $ScriptVersion\"<br>Write-ToLogFile -Message \"Wijzigingsdatum = $ScriptChangeDate\"<br>Write-ToLogFile -Message \"Wijzigingslog = $ScriptChangeLog\"<br>Write-ToLogFile -Message \"Gebruiker die dit script uitvoert = $ScriptCurrentUser\"<br>Write-ToLogFile -Message \"Apparaat waarop dit script draait = $ScriptRunningDevice\"<br>Write-ToLogFile -Message \"Publiek IP-adres = $PublicIP\"<br>Write-ToLogFile -Message \"Priv\u00e9 IP-adres = $PrivateIP\"<br>Write-ToLogFile -Message \"Gewenste TAP-configuratie: DefaultLifetime=$DefaultLifetimeInMinutes, MinimumLifetime=$MinimumLifetimeInMinutes, MaximumLifetime=$MaximumLifetimeInMinutes, TapLength=$TapLength, UsableOnce=$UsableOnce\"<br><br>try {<br>    Start-Transcript -Path $TranscriptFile -Force | Out-Null<br>}<br>catch {<br>    Write-ToLogFile -Level \"WARN\" -Message \"Transcript kon niet worden gestart: $($_.Exception.Message)\"<br>}<br>#endregion Script start<br><br>try {<br>    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12<br>    Write-ToLogFile -Message \"TLS 1.2 is ingesteld.\"<br><br>    Write-ToLogFile -Message \"Valideren van TAP-parameters.\"<br>    Test-TapParameters<br>    Write-ToLogFile -Message \"TAP-parameters zijn geldig.\"<br><br>    Write-ToLogFile -Message \"Controle op Microsoft.Graph module gestart.\"<br>    Install-MicrosoftGraphModule<br><br>    Write-ToLogFile -Message \"Verbinding maken met Microsoft Graph.\"<br>    Connect-MgGraph -Scopes \"Policy.ReadWrite.AuthenticationMethod\" -ErrorAction Stop | Out-Null<br><br>    $Context = Get-MgContext<br>    Write-ToLogFile -Message \"Verbonden met tenant: $($Context.TenantId)\"<br>    Write-ToLogFile -Message \"Verbonden met account: $($Context.Account)\"<br><br>    Write-ToLogFile -Message \"Huidige TAP-configuratie ophalen.\"<br>    $TapBefore = Get-MgPolicyAuthenticationMethodPolicyAuthenticationMethodConfiguration `<br>        -AuthenticationMethodConfigurationId 'temporaryAccessPass' `<br>        -ErrorAction Stop<br><br>    Write-ToLogFile -Message (<br>        \"Huidige TAP-configuratie: \" +<br>        \"State=$($TapBefore.state), \" +<br>        \"IsUsableOnce=$($TapBefore.isUsableOnce), \" +<br>        \"Length=$($TapBefore.length), \" +<br>        \"MinimumLifetime=$($TapBefore.minimumLifetimeInMinutes), \" +<br>        \"DefaultLifetime=$($TapBefore.defaultLifetimeInMinutes), \" +<br>        \"MaximumLifetime=$($TapBefore.maximumLifetimeInMinutes)\"<br>    )<br><br>    $Body = @{<br>        \"@odata.type\"            = \"#microsoft.graph.temporaryAccessPassAuthenticationMethodConfiguration\"<br>        state                    = \"enabled\"<br>        isUsableOnce             = $UsableOnce<br>        defaultLifetimeInMinutes = $DefaultLifetimeInMinutes<br>        minimumLifetimeInMinutes = $MinimumLifetimeInMinutes<br>        maximumLifetimeInMinutes = $MaximumLifetimeInMinutes<br>        length                   = $TapLength<br>    }<br><br>    Write-ToLogFile -Message \"Nieuwe TAP-configuratie toepassen.\"<br>    Update-MgPolicyAuthenticationMethodPolicyAuthenticationMethodConfiguration `<br>        -AuthenticationMethodConfigurationId 'temporaryAccessPass' `<br>        -BodyParameter $Body `<br>        -ErrorAction Stop<br><br>    Write-ToLogFile -Message \"Nieuwe TAP-configuratie succesvol toegepast.\"<br><br>    Write-ToLogFile -Message \"Nieuwe TAP-configuratie verifi\u00ebren.\"<br>    $TapAfter = Get-MgPolicyAuthenticationMethodPolicyAuthenticationMethodConfiguration `<br>        -AuthenticationMethodConfigurationId 'temporaryAccessPass' `<br>        -ErrorAction Stop<br><br>    Write-ToLogFile -Message (<br>        \"Nieuwe TAP-configuratie: \" +<br>        \"State=$($TapAfter.state), \" +<br>        \"IsUsableOnce=$($TapAfter.isUsableOnce), \" +<br>        \"Length=$($TapAfter.length), \" +<br>        \"MinimumLifetime=$($TapAfter.minimumLifetimeInMinutes), \" +<br>        \"DefaultLifetime=$($TapAfter.defaultLifetimeInMinutes), \" +<br>        \"MaximumLifetime=$($TapAfter.maximumLifetimeInMinutes)\"<br>    )<br><br>    if (-not $Silent) {<br>        Write-Host \"\"<br>        Write-Host \"--- TAP policy na update ---\"<br>        $TapAfter |<br>            Select-Object `<br>                state,<br>                isUsableOnce,<br>                length,<br>                minimumLifetimeInMinutes,<br>                defaultLifetimeInMinutes,<br>                maximumLifetimeInMinutes |<br>            Format-Table -AutoSize<br>        Write-Host \"\"<br>    }<br>}<br>catch {<br>    Write-ToLogFile -Level \"ERROR\" -Message \"Er is een fout opgetreden: $($_.Exception.Message)\"<br>    Write-Error \"Het script is mislukt: $($_.Exception.Message)\"<br>    throw<br>}<br>finally {<br>    try {<br>        Disconnect-MgGraph -ErrorAction SilentlyContinue | Out-Null<br>        Write-ToLogFile -Message \"Microsoft Graph-verbinding is gesloten.\"<br>    }<br>    catch {<br>        Write-ToLogFile -Level \"WARN\" -Message \"Microsoft Graph kon niet netjes worden afgesloten.\"<br>    }<br><br>    try {<br>        Stop-Transcript | Out-Null<br>    }<br>    catch {<br>        Write-ToLogFile -Level \"WARN\" -Message \"Transcript kon niet worden gestopt.\"<br>    }<br><br>    try {<br>        if (Test-Path -Path $IntuneLogPath) {<br>            Copy-Item -Path $TranscriptFile -Destination $IntuneLogPath -Force<br>            Write-ToLogFile -Message \"Transcriptbestand gekopieerd naar: $IntuneLogPath\"<br>        }<br>        else {<br>            Write-ToLogFile -Level \"WARN\" -Message \"Doelmap voor Intune-logs bestaat niet: $IntuneLogPath\"<br>        }<br>    }<br>    catch {<br>        Write-ToLogFile -Level \"WARN\" -Message \"Kopi\u00ebren van transcriptbestand is mislukt: $($_.Exception.Message)\"<br>    }<br>}<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">Wanneer gebruik je TAP?<\/h1>\n\n\n\n<p>Een paar situaties waarin TAP ideaal is.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Nieuwe medewerker<\/h3>\n\n\n\n<p>Nieuwe gebruiker krijgt TAP om:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>eerste login te doen<\/li>\n\n\n\n<li>MFA te configureren<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Nieuwe telefoon<\/h3>\n\n\n\n<p>Gebruiker heeft een nieuwe telefoon.<\/p>\n\n\n\n<p>Met TAP kan hij eenvoudig <strong>MFA opnieuw instellen<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Recovery scenario<\/h3>\n\n\n\n<p>Als MFA volledig stuk is, kan TAP gebruikt worden als <strong>veilige tijdelijke toegang<\/strong>.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Conclusie<\/h1>\n\n\n\n<p>Temporary Access Pass is een van de <strong>meest onderschatte features van Microsoft Entra ID<\/strong>.<\/p>\n\n\n\n<p>Met een goede configuratie kun je:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>MFA onboarding verbeteren<\/li>\n\n\n\n<li>support tickets verminderen<\/li>\n\n\n\n<li>recovery eenvoudiger maken<\/li>\n\n\n\n<li>veiligheid behouden<\/li>\n<\/ul>\n\n\n\n<p>Door dit via PowerShell te automatiseren hoef je het <strong>maar \u00e9\u00e9n keer goed in te richten<\/strong>.<\/p>\n\n\n\n<p>Daarna laat je het script het werk doen.<\/p>\n\n\n\n<p>Precies zoals het hoort.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Iedere beheerder kent het wel. Een gebruiker kan niet meer inloggen omdat: Dan begint vaak het bekende proces<\/p>\n","protected":false},"author":2,"featured_media":126,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,6],"tags":[],"class_list":["post-123","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-powershell"],"_links":{"self":[{"href":"https:\/\/unen.nl\/index.php?rest_route=\/wp\/v2\/posts\/123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unen.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unen.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unen.nl\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/unen.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=123"}],"version-history":[{"count":2,"href":"https:\/\/unen.nl\/index.php?rest_route=\/wp\/v2\/posts\/123\/revisions"}],"predecessor-version":[{"id":128,"href":"https:\/\/unen.nl\/index.php?rest_route=\/wp\/v2\/posts\/123\/revisions\/128"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unen.nl\/index.php?rest_route=\/wp\/v2\/media\/126"}],"wp:attachment":[{"href":"https:\/\/unen.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unen.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unen.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}