Helpers/Renew-AGGraphAccessToken.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
Function Renew-AGGraphAccessToken{ <# .SYNOPSIS This will renew the existing Token if it will expire in 5 minutes or less .DESCRIPTION This will renew the existing Token if it will expire in 5 minutes or less .EXAMPLE Renew-AGGraphAccessToken .NOTES Author: Lars Panzerbjørn Creation Date: 2021.10.19 #> IF(!($TokenResponse.ExpiresOn -ge $((Get-Date).AddMinutes(5)))){ Get-AGGraphAccessToken -TenantID $TenantID -ClientID $ClientId -ClientSecret $ClientSecret } } |