Repository navigation
Closed
PowerShell/PowerShellEditorServices
#1227Labels
Milestone
Description
System Details
System Details Output
### VSCode version: 1.41.1 26076a4de974ead31f97692a0d32f90d735645c0 x64
### VSCode extensions:
[email protected]
### PSES version:
### PowerShell version:
Name Value
---- -----
PSVersion 5.1.14393.3383
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.3383
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Issue Description
I am experiencing a problem with running cmdlets from MicrosoftPowerBIMgmt module. Same script works as expected in ISE but fails in Visual Studio Code.
I am unable to run Get-PowerBIActivityEvent
I believe the issue could be caused by version of the Newtonsoft.Json.dll that came with December version of the Powershell extension - it is 11.0.0 while the module requires 12.0.2 and higher
PS C:\Windows\system32> [Newtonsoft.Json.JsonConvert].Module
MDStreamVersion : 131072
FullyQualifiedName : C:\Users\****\.vscode\extensions\ms-vscode.powershell-2019.12.0\modules\PowerShellEditorServices\bin\Desktop\Newtonsoft.Json.dll
ModuleVersionId : 07e38931-19a9-45b2-9a35-e81930b1c8ad
MetadataToken : 1
ScopeName : Newtonsoft.Json.dll
Name : Newtonsoft.Json.dll
Assembly : Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
CustomAttributes : {}
ModuleHandle : System.ModuleHandle`
Expected Behaviour
execution the same cmdlet in ISE returns results as expected with no errors.
Actual Behaviour
I get the following error:
Get-PowerBIActivityEvent : Attempted to access an element as a type incompatible with the array.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...BIActivityEvent:GetPowerBIActivityEvent) [Get-PowerBIActivityEvent], ArrayTypeMismatchException
+ FullyQualifiedErrorId : Attempted to access an element as a type incompatible with the array.,Microsoft.PowerBI.Commands.Admin.GetPowerBIActivityEvent
Activity
rjmholt commentedon Jan 2, 2020
olyamusok this issue should be fixed in the latest
powershell-previewextension. Could you uninstall thepowershellextension, installpowershell-previewand see if that resolves the issue?olyamusok commentedon Jan 3, 2020
Rob Holt (@rjmholt) I uninstalled
powershellextensions and installedpowershell-preview. The error is gone and the script runs, but output is missing all values for key-value pairs.I get an empty shell like this for each activity while the output I get from running same code in ISE is just fine:
here is NewtonSoft module I see for
powershell-previewrjmholt commentedon Jan 3, 2020
Thanks for trying that out! I now have a similar repro (I'm not familiar with the MicrosoftPowerBIMgmt module and don't have any PowerBI workspaces, but have hit an error earlier on that I think has the same root cause).
The PowerShell extension has a hard dependency on Newtonsoft.Json (as does PSScriptAnalyzer). Since PowerShell 6+ also ships with Newtonsoft.Json, we version to that.
After taking on new dependencies when rearchitecting the PowerShell extension, we did some work to isolate those dependencies when possible. It seems that the .NET Framework side of that work didn't solve the problem. However, experimenting with different solutions suggests that the problem may not be solvable in .NET Framework.
We have, however, solved the problem in .NET Core. I tried this in PowerShell 6 and 7 and it seems to work normally in those.
rjmholt commentedon Jan 3, 2020
I'll continue playing with the .NET Framework solution to see if there's a possible solution, but I'm not optimistic.
olyamusok commentedon Jan 6, 2020
Rob Holt (@rjmholt) thank you for looking into this in any case! I will keep this open for a bit longer in case something new will come up and will close in a month or so if not.
Also can confirm that the code and cmdlets work just fine in VS code with
PowerShell-previewafter I also installed PowerShell 7 preview on that same machine.SydneyhSmith commentedon Mar 5, 2020
Closing as PS7 is now GA
4 remaining items
TylerLeonhardt commentedon Mar 10, 2020
This does not install PowerShell itself. We're only talking about the PowerShell extension and PowerShell Preview extension. You don't need to install anything else other than that VSIX
rjmholt commentedon Mar 10, 2020
Oh wow, rereading my comment I totally see the confusion. Yeah this installs the PowerShell extension for VSCode, not PowerShell the program. It will use the normal
powershell.exe.olyamusok commentedon Mar 12, 2020
Rob Holt (@rjmholt) apologies for delayed response, just saw the tag. Glad @soulwiper was able to test.
rjmholt commentedon Mar 12, 2020
olyamusok I believe @soulwiper is experiencing a different issue, which it turns out isn't fixed by this. We're going to try a fix for your issue in the next preview release
TylerLeonhardt commentedon Mar 13, 2020
Can you all give the PowerShell Preview extension a try? We just did a release of it.
Don't forget to disable the regular PowerShell extension for VS Code when you enable the PowerShell Preview extension for VS Code
sqlchick commentedon Jun 14, 2020
Thank you, thank you, thank you olyamusok for commenting about installation of PowerShell 7 -- I also was getting blank [ ] results in VSCode when running Get-PowerBIActivityEvent, while getting results returned just fine from the ISE. At this time, version 7.0.2 (https://github.com/PowerShell/PowerShell/releases) is the latest & whatever it installed resolved the issue. (And just for completeness on this thread...the Powershell preview extension in VSCode also had no effect for me on this particular issue that I was facing.)