[BUG] - Error calling Register-PnPManagementShellAccess
Reporting an Issue or Missing Feature
When trying to run Register-PnPManagementShellAccess in Visual Studio code, the Intergated Powershell console throws an error
Expected behavior
Run Register-PnPManagementShellAccess Copy Code Open Browser Paste Code Authentication
Actual behavior
Run Register-PnPManagementShellAccess
Error appears:
Register-PnPManagementShellAccess: The WriteObject and WriteError methods cannot be called from outside the overrides of the BeginProcessing, ProcessRecord, and EndProcessing methods, and they can only be called from within the same thread. Validate that the cmdlet makes these calls correctly, or contact Microsoft Customer Support Services.
Steps to reproduce behavior
Run Register-PnPManagementShellAccess Using version 1.50.1 of VSCode
Running the command in the Windows Terminal is successful.
What is the version of the Cmdlet module you are running?
Running preview version 0.1.29 of the Cmdlet
Hi! I just tried but I cannot reproduce this issue... Register-PnPManagementShell access works on my end without a problem. Which version of PowerShell are you running VSCode? 5, 6 or 7?
Same issue here. I believe it has to do with the debugger calling the code in another thread.
VSCode Version: 1.51.1 Powershell Version: 7.1.0
I am using:
VSCode: 1.51.1 I've tried PowerShell versions - 7.1.0 and 7.2.0 [Preview]
Still get the same issue.
I can run the commands in the windows terminal, however, as soon as I run either Register-PnPManagementShellAccess or Connect-PnPOnline -PnPManagementShell in VSCode I get the same error again.
Connect-PnPOnline: The WriteObject and WriteError methods cannot be called from outside the overrides of the BeginProcessing, ProcessRecord, and EndProcessing methods, and they can only be called from within the same thread. Validate tha called from within the same thread. Validate that the cmdlet makes these calls correctly, or contact Microsoft Customer Support Services.
I have the same issue,
VSCODE = Version: 1.51.1 (user setup) POWERSHELL = 7.1.0
I can connect with the cmdlet connect-pnponline -url ... -credentials (get-credential) i can connect with using -returnconnection -clientID ... -clientsecret
When i try to use -PnPManagementShell it returns an error: ` PS C:\GITREPO\DEV_PnP.Powershell> Connect-PnPOnline -Url $Siteurl -PnPManagementShell
Connect-PnPOnline: The WriteObject and WriteError methods cannot be called from outside the overrides of the BeginProcessing, ProcessRecord, and EndProcessing methods, and they can only be called from within the same thread. Validate that the cmdlet makes these calls correctly, or contact Microsoft Customer Support Services.
PS C:\GITREPO\DEV_PnP.Powershell>
if i try to run "Register-PnPManagementShell "
PS C:\GITREPO\DEV_PnP.Powershell> Register-PnPManagementShell
Register-PnPManagementShell: The term 'Register-PnPManagementShell' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\GITREPO\DEV_PnP.Powershell> `
other thing like get list create lists etc works,
Also Get-PnPSiteTemplate returns an error, it first starts with generate a template, but returns with the following issue
PS C:\GITREPO\DEV_PnP.Powershell> Get-PnPSiteTemplate -Out ".\Template.xml"
Get-PnPSiteTemplate: {"error_description":"Invalid issuer or signature."}
PS C:\GITREPO\DEV_PnP.Powershell>
@Nibushi , @get-mrsmit : We actually released a new nightly build (0.3.9-nightly) which should solve this issue. Can you please test it and see if it works for you with this release?
@erwinvanhunen , sorry for the delay. I will take a look at this today and get back to you. Apologies once again
No worries!
@erwinvanhunen - I can confirm that the command now works for me as expected using build 0.3.14-nightly.
A new browser window is opened and the code is copied to the clipboard. I am able to then paste this code and successfully authenticate.
This now looks like it is working as expected.
Thanks for your help in looking into this issue.
Have a good Christmas!
Cheers Simon
I do not know if it can be helpful to anyone, but since I figured out a solution that worked for me, I thought of adding it to the thread. Here is the solution Register-PnPManagementShellAccess is not recognized