functions/Public/Authorization/Remove-MgaToken.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
function Remove-MgaToken { <# .LINK https://github.com/baswijdenes/Optimized.Mga/ .LINK https://baswijdenes.com/c/microsoft/mga/ .SYNOPSIS Use Remove-MgaToken to remove the MgaSession HashTable from the Script scope. .DESCRIPTION To refresh the AccessToken, I use a Hashtable in the script scope with a number of properties. The properties are emptied by Remove-MgaToken. .EXAMPLE Remove-MgaToken #> [CmdletBinding()] param ( ) begin { Write-Verbose 'Removing MgaSession Variable in Scope script' } process { try { $Null = Get-Variable -Name 'Mga*' -Scope Script | Remove-Variable -Force -Scope Script } catch { throw $_.Exception.Message } } end { return "MgaSession is removed" } } |