From e924984763971e00713482eebd79b2ce83714c31 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Peters Date: Mon, 29 Jan 2024 14:37:29 +0100 Subject: [PATCH 1/2] Remove unsupported parameter --- MiniGraph/functions/Invoke-GraphRequestBatch.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MiniGraph/functions/Invoke-GraphRequestBatch.ps1 b/MiniGraph/functions/Invoke-GraphRequestBatch.ps1 index 876b912..ab6abd5 100644 --- a/MiniGraph/functions/Invoke-GraphRequestBatch.ps1 +++ b/MiniGraph/functions/Invoke-GraphRequestBatch.ps1 @@ -189,7 +189,7 @@ } try { - (MiniGraph\Invoke-GraphRequestBatch -Name $Name -Request $retry -NoProgress -ErrorAction Stop).responses + (MiniGraph\Invoke-GraphRequestBatch -Request $retry -ErrorAction Stop).responses } catch { Write-Error -Message "Error sending retry batch: $($_.Exception.Message)" -TargetObject $retry From 48b2147491d6323f8f722ffe36030c569fb1d122 Mon Sep 17 00:00:00 2001 From: FriedrichWeinmann Date: Tue, 5 Mar 2024 21:49:34 +0100 Subject: [PATCH 2/2] added token retrieval --- MiniGraph/MiniGraph.psd1 | 3 ++- MiniGraph/functions/Connect-GraphBrowser.ps1 | 7 ++--- MiniGraph/functions/Get-GraphToken.ps1 | 28 ++++++++++++++++++++ changelog.md | 6 +++++ 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 MiniGraph/functions/Get-GraphToken.ps1 diff --git a/MiniGraph/MiniGraph.psd1 b/MiniGraph/MiniGraph.psd1 index 1c297e9..a6c3dc7 100644 --- a/MiniGraph/MiniGraph.psd1 +++ b/MiniGraph/MiniGraph.psd1 @@ -4,7 +4,7 @@ RootModule = 'MiniGraph.psm1' # Version number of this module. -ModuleVersion = '1.3.13' +ModuleVersion = '1.3.16' # Supported PSEditions # CompatiblePSEditions = @() @@ -69,6 +69,7 @@ FunctionsToExport = @( 'Connect-GraphCredential' 'Connect-GraphDeviceCode' 'Connect-GraphToken' + 'Get-GraphToken' 'Invoke-GraphRequest' 'Invoke-GraphRequestBatch' 'Set-GraphEndpoint' diff --git a/MiniGraph/functions/Connect-GraphBrowser.ps1 b/MiniGraph/functions/Connect-GraphBrowser.ps1 index c74130b..c4bcf4f 100644 --- a/MiniGraph/functions/Connect-GraphBrowser.ps1 +++ b/MiniGraph/functions/Connect-GraphBrowser.ps1 @@ -40,7 +40,7 @@ The path to the browser to use for the authentication flow. Provide the full path to the executable. The browser must accept the url to open as its only parameter. - Defaults to Edge. + Defaults to your default browser. .PARAMETER NoReconnect Disables automatic reconnection. @@ -74,7 +74,7 @@ $Resource = 'https://graph.microsoft.com/', [string] - $Browser = $script:browserPath, + $Browser, [switch] $NoReconnect @@ -124,7 +124,8 @@ catch { Invoke-TerminatingException -Cmdlet $PSCmdlet -Message "Failed to create local http listener on port $LocalPort. Use -LocalPort to select a different port. $_" -Category OpenError } # Execute in default browser - & $Browser $uriFinal + if ($Browser) { & $Browser $uriFinal } + else { Start-Process $uriFinal } # Get Result $task = $http.GetContextAsync() diff --git a/MiniGraph/functions/Get-GraphToken.ps1 b/MiniGraph/functions/Get-GraphToken.ps1 new file mode 100644 index 0000000..8dccaa4 --- /dev/null +++ b/MiniGraph/functions/Get-GraphToken.ps1 @@ -0,0 +1,28 @@ +function Get-GraphToken { + <# + .SYNOPSIS + Retrieve the currently used graph token. + + .DESCRIPTION + Retrieve the currently used graph token. + Use one of the Connect-Graph* commands to first establish a connection. + The token retrieved is a static copy of the current token - it will not be automatically refreshed once expired. + + .EXAMPLE + PS C:\> Get-GraphToken + + Retrieve the currently used graph token. + #> + [CmdletBinding()] + param ( + + ) + process { + [PSCustomObject]@{ + Token = $script:token + Created = $script:lastConnect.When + HasRefresh = $script:lastConnect.Refresh -as [bool] + Endpoint = $script:baseEndpoint + } + } +} \ No newline at end of file diff --git a/changelog.md b/changelog.md index 6d64592..5feb871 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 1.3.16 (2024-03-05) + ++ New: Get-GraphToken - retrieve the currently used token ++ Upd: Connect-GraphBrowser - opens logon screen in the default browser by default ++ Fix: Invoke-GraphRequestBatch - retries stop failing + ## 1.3.13 (2023-12-03) + Upd: Invoke-GraphRequestBatch - simplified requests specification