Skip to content

Powershell freezes when using Invoke-GraphRequest and WPF #390

Closed

Description

I have come across a problem where if I trigger Invoke-GraphRequest from a WPF button the command freezes.
This seems to affect at least getting a list of onenote section groups or sections or pages

I have tried debugging in VSCode setting a breakpoint on the line that runs Invoke-GraphRequest and it also does the same thing.
Below created an example using minimal code.
I have also included Get-MgGroupOnenoteNotebookSectionGroup which works fine and returns the correct result.
Please enter the top 3 variables for testing (removed as they were specific to my tenant)

#a group id from graph which could be retrieve using Get-MgGroup
$groupid = ""
#a notebook id from graph which could be retrieve using Get-MgGroupOnenoteNotebook
$notebookid = ""
#a section group uri from (Get-MgGroupOnenoteNotebook -groupid $groupid -notebookid $notebookid).sectionGroupsUrl
$sectiongroupsuri = ""

#Make sure we are authenticated to graph
Connect-Graph  -scope @("Notes.ReadWrite.All","Group.Read.All","Sites.Read.All") | out-null

#build ui
Add-Type -AssemblyName PresentationFramework

[xml]$xaml = @"
<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    Title="Window" Height="200" Width="300">
    <Grid Background="#FFECECEC">
    <Button Name="button1" Content="Get-MgGroupOnenoteNotebookSectionGroup" HorizontalAlignment="Left" Margin="10,10,10,10" VerticalAlignment="Top"/>
    <Button Name="button2" Content="Invoke-GraphRequest" HorizontalAlignment="Left" Margin="10,50,10,10" VerticalAlignment="Top"/>
    </Grid>
    </Window>
"@


$reader = (New-Object System.Xml.XmlNodeReader $xaml)

$window = [Windows.Markup.XamlReader]::Load($reader)

$button1 = $window.FindName("button1")

$button1.Add_Click( {
    write-host (Get-MgGroupOnenoteNotebookSectionGroup -GroupId $groupid -NotebookId $notebookid | out-string)
})

$button2 = $window.FindName("button2")

$button2.Add_Click( {
    write-host (Invoke-GraphRequest -uri $sectiongroupsuri | out-string)
})


$window.ShowDialog()

Activity

  1. TobyHawkes commented on Oct 1, 2020

    @TobyHawkes
    Author

    I can confirm the issue persists in v1.0.1. Note I am trying from powershell 5.1. I have tested in both VSCode and directly running the script and both have the same issue

  2. TobyHawkes commented on Dec 8, 2020

    @TobyHawkes
    Author

    tested - all works now on v1.2.0, thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions