You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling the Get-MgUser and other Microsoft.Graph functions often cause my scripts to fail with this error:
format-default: There is no Runspace available to run scripts in this thread. You can provide one in the DefaultRunspace property of the System.Management.Automation.Runspaces.Runspace type. The script block you attempted to invoke was:
…
The problem is more reproducible on virtual machines with 2 virtual CPUs. It seems this occurs when the Microsoft.Graph objects are emitted to the pipeline.
Expected behavior
Emitting Microsoft.Graph object to the pipeline (or screen) should not terminate PowerShell scripts.
How to reproduce
Deploy a Hyper-V VM running Windows 11 with 2 vCPU and 4 GB RAM
Execute the script. For example: .\Test-format-default.ps1 -User "John Doe" -Provider Graph
On a 2 vCPU VM, this tends to fail in less than 20 iterations, often in less than 10 iterations. On a 4 vCPU VM, this may not fail in the 100 iterations but I sometimes see it fail after many iterations. If you use the -Provider EXO, it never fails which is why it appears to be a bug in the Microsoft.Graph modules.
Using more virtual CPUs seems to decrease the frequency of the issue but may not avoid it completely.
Not allowing the object to be emitted to the pipeline seems to work around the issue. For example, if you only return one property of the object to the pipeline, e.g $MGUser.UserPrincipalName, then the error does not occur.
Does not occur when -Debug argument is used with Get-MGUser
Debug output
Click to expand log
```
</details>
### Configuration
-OS: Windows 11
-Architecture: x64
```powershell
Name Value
---- -----
PSVersion 7.4.5
PSEdition Core
GitCommitId 7.4.5
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Other information
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
Calling the Get-MgUser and other Microsoft.Graph functions often cause my scripts to fail with this error:
format-default: There is no Runspace available to run scripts in this thread. You can provide one in the DefaultRunspace property of the System.Management.Automation.Runspaces.Runspace type. The script block you attempted to invoke was:
…
The problem is more reproducible on virtual machines with 2 virtual CPUs. It seems this occurs when the Microsoft.Graph objects are emitted to the pipeline.
Expected behavior
Emitting Microsoft.Graph object to the pipeline (or screen) should not terminate PowerShell scripts.
How to reproduce
.\Test-format-default.ps1 -User "John Doe" -Provider Graph
On a 2 vCPU VM, this tends to fail in less than 20 iterations, often in less than 10 iterations. On a 4 vCPU VM, this may not fail in the 100 iterations but I sometimes see it fail after many iterations. If you use the -Provider EXO, it never fails which is why it appears to be a bug in the Microsoft.Graph modules.
SDK Version
ModuleType Version PreRelease Name ExportedCommands ---------- ------- ---------- ---- ---------------- Script 2.24.0 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-M… Script 2.24.0 Microsoft.Graph.Users {Get-MgUser, Get-MgUserCount, Get-MgUserCreatedOb…
Latest version known to work for scenario above?
No response
Known Workarounds
Debug output
Click to expand log
```Other information
No response
The text was updated successfully, but these errors were encountered: