Skip to content

Issue running cmdltes from MicrosoftPowerBIMgmt Module #2397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
olyamusok opened this issue Jan 2, 2020 · 18 comments · Fixed by PowerShell/PowerShellEditorServices#1227
Closed
Assignees
Labels
Area-Engine Issue-Bug A bug to squash. Needs: Fix Verification Please verify the fix for us!
Milestone

Comments

@olyamusok
Copy link

olyamusok commented Jan 2, 2020

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

@rjmholt
Copy link
Contributor

rjmholt commented Jan 2, 2020

@olyamusok this issue should be fixed in the latest powershell-preview extension. Could you uninstall the powershell extension, install powershell-preview and see if that resolves the issue?

@olyamusok
Copy link
Author

olyamusok commented Jan 3, 2020

@rjmholt I uninstalled powershell extensions and installed powershell-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:

[
  {
    "Id": [],
    "RecordType": [],
    "CreationTime": [],
    "Operation": [],
    "OrganizationId": [],
    "UserType": [],
    "UserKey": [],
    "Workload": [],
    "UserId": [],
    "ClientIP": [],
    "UserAgent": [],
    "Activity": [],
    "ItemName": [],
    "WorkSpaceName": [],
    "DatasetName": [],
    "WorkspaceId": [],
    "ObjectId": [],
    "DatasetId": [],
    "DataConnectivityMode": [],
    "IsSuccess": [],
    "RequestId": [],
    "ActivityId": [],
    "TableName": []
  },
  {
    "Id": [],
    "RecordType": [],
    "CreationTime": [],
    "Operation": [],
    "OrganizationId": [],
    "UserType": [],
    "UserKey": [],
    "Workload": [],
    "UserId": [],
    "ClientIP": [],
    "UserAgent": [],
    "Activity": [],
    "ItemName": [],
    "WorkSpaceName": [],
    "DatasetName": [],
    "ReportName": [],
    "WorkspaceId": [],
    "ObjectId": [],
    "DatasetId": [],
    "ReportId": [],
    "IsSuccess": [],
    "ReportType": [],
    "RequestId": [],
    "ActivityId": [],
    "DistributionMethod": []
  },

here is NewtonSoft module I see for powershell-preview

> PS C:\windows\system32> [Newtonsoft.Json.JsonConvert].Module

MDStreamVersion    : 131072
FullyQualifiedName : C:\Users\***\.vscode\extensions\ms-vscode.powershell-preview-2019.12.0\modules\PowerShellEditorServices\bin\Common\Newtonsoft.Json.dll
ModuleVersionId    : d32db49e-5e34-4072-9da3-1845c03ddc3a
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

@rjmholt
Copy link
Contributor

rjmholt commented 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
Copy link
Contributor

rjmholt commented 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
Copy link
Author

olyamusok commented Jan 6, 2020

@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-preview after I also installed PowerShell 7 preview on that same machine.

@SydneyhSmith SydneyhSmith added Area-Engine Issue-Bug A bug to squash. Needs: Fix Verification Please verify the fix for us! and removed Needs: Triage Maintainer attention needed! labels Jan 7, 2020
@SydneyhSmith SydneyhSmith added this to the 2.0.0 milestone Jan 30, 2020
@SydneyhSmith
Copy link
Collaborator

Closing as PS7 is now GA

@rjmholt
Copy link
Contributor

rjmholt commented Mar 10, 2020

@olyamusok can you try out this extension package for me and see if the issue persists?

psvsix.zip

It's a zip file, since GitHub won't allow uploading a VSIX directly. To install it, do this:

# Download psvsix.zip to current directory

# Extract zip
Expand-Archive ./psvsix.zip ./psvsix

# Install to VSCode
code --install-extension ./psvsix/PowerShell-Insiders.vsix

# Open VSCode
# Ensure the PowerShell Preview is installed and the PowerShell extension is disabled
# Close and reopen VSCode
# Try your repro steps

@soulwiper
Copy link

I don't have PowerShell-Insiders (I don't think). Is that going to be a problem? How do I tell if I have PowerShell-Insiders?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Mar 10, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Mar 10, 2020

That VSIX linked above will install “PowerShell Insiders” rather than “PowerShell”. It will appear as a separate VSCode extension. So after you install that VSIX you need to uninstall or disable the “PowerShell” extension and restart VSCode. Then “PowerShell Insiders” will start up

@TylerLeonhardt
Copy link
Member

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
Copy link
Contributor

rjmholt commented Mar 10, 2020

This does not install PowerShell itself.

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.

@soulwiper
Copy link

soulwiper commented Mar 10, 2020 via email

@soulwiper
Copy link

soulwiper commented Mar 11, 2020

Even with the preview (psvsix.zip) you requested me to try out I still run into the same problem as before. I can not debug and language issue prompt poping up.

However I did not an error poping up for a second on the terminal before and with the preview. I did not think of capturing it. I have attached it as an jpeg image below.

PowerShell preview extention error messages before blank terminal (with diagnostic)

and the log output:
3/10/2020 9:35:55 PM [NORMAL] - Visual Studio Code v1.42.1 64-bit
3/10/2020 9:35:55 PM [NORMAL] - PowerShell Extension v2020.3.0
3/10/2020 9:35:55 PM [NORMAL] - Operating System: Windows 64-bit
3/10/2020 9:35:55 PM [NORMAL] - Language server starting --
3/10/2020 9:35:55 PM [NORMAL] - PowerShell executable: C:\Users\czachariou.dotnet\tools\pwsh.exe
3/10/2020 9:35:55 PM [NORMAL] - PowerShell args: -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command Import-Module 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\logs\1583894155-02660d03-e13b-43f8-8e43-c76d363230961583894154248\EditorServices.log' -SessionDetailsPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\sessions\PSES-VSCode-13904-355584' -FeatureFlags @()
3/10/2020 9:35:55 PM [NORMAL] - PowerShell Editor Services args: Import-Module 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\logs\1583894155-02660d03-e13b-43f8-8e43-c76d363230961583894154248\EditorServices.log' -SessionDetailsPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\sessions\PSES-VSCode-13904-355584' -FeatureFlags @()
3/10/2020 9:35:55 PM [NORMAL] - pwsh.exe started.
3/10/2020 9:35:55 PM [NORMAL] - Waiting for session file
3/10/2020 9:37:56 PM [NORMAL] - Error occurred retrieving session file:
Timed out waiting for session file to appear.
3/10/2020 9:37:56 PM [NORMAL] - Language server startup failed.
3/10/2020 9:37:56 PM [ERROR] - The language service could not be started:
3/10/2020 9:37:56 PM [ERROR] - Timed out waiting for session file to appear.
3/10/2020 9:42:52 PM [NORMAL] - Shutting down language client...
3/10/2020 9:42:52 PM [NORMAL] - Language server starting --
3/10/2020 9:42:52 PM [NORMAL] - PowerShell executable: C:\Users\czachariou.dotnet\tools\pwsh.exe
3/10/2020 9:42:52 PM [NORMAL] - PowerShell args: -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command Import-Module 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Diagnostic' -LogPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\logs\1583894572-02660d03-e13b-43f8-8e43-c76d363230961583894154248\EditorServices.log' -SessionDetailsPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\sessions\PSES-VSCode-13904-903383' -FeatureFlags @()
3/10/2020 9:42:52 PM [NORMAL] - PowerShell Editor Services args: Import-Module 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Diagnostic' -LogPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\logs\1583894572-02660d03-e13b-43f8-8e43-c76d363230961583894154248\EditorServices.log' -SessionDetailsPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\sessions\PSES-VSCode-13904-903383' -FeatureFlags @()
3/10/2020 9:42:52 PM [NORMAL] - pwsh.exe started.
3/10/2020 9:42:52 PM [NORMAL] - Waiting for session file
3/10/2020 9:43:11 PM [NORMAL] - Shutting down language client...
3/10/2020 9:43:11 PM [NORMAL] - Terminating PowerShell process...
3/10/2020 9:43:11 PM [NORMAL] - Language server starting --
3/10/2020 9:43:11 PM [NORMAL] - PowerShell executable: C:\Users\czachariou.dotnet\tools\pwsh.exe
3/10/2020 9:43:11 PM [NORMAL] - PowerShell args: -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command Import-Module 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\logs\1583894591-02660d03-e13b-43f8-8e43-c76d363230961583894154248\EditorServices.log' -SessionDetailsPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\sessions\PSES-VSCode-13904-295959' -FeatureFlags @()
3/10/2020 9:43:11 PM [NORMAL] - PowerShell Editor Services args: Import-Module 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\logs\1583894591-02660d03-e13b-43f8-8e43-c76d363230961583894154248\EditorServices.log' -SessionDetailsPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\sessions\PSES-VSCode-13904-295959' -FeatureFlags @()
3/10/2020 9:43:11 PM [NORMAL] - pwsh.exe started.
3/10/2020 9:43:11 PM [NORMAL] - Waiting for session file
3/10/2020 9:44:52 PM [NORMAL] - Error occurred retrieving session file:
Timed out waiting for session file to appear.
3/10/2020 9:44:52 PM [NORMAL] - Language server startup failed.
3/10/2020 9:44:52 PM [ERROR] - The language service could not be started:
3/10/2020 9:44:52 PM [ERROR] - Timed out waiting for session file to appear.
3/10/2020 9:45:12 PM [NORMAL] - Error occurred retrieving session file:
Timed out waiting for session file to appear.
3/10/2020 9:45:12 PM [NORMAL] - Language server startup failed.
3/10/2020 9:45:12 PM [ERROR] - The language service could not be started:
3/10/2020 9:45:12 PM [ERROR] - Timed out waiting for session file to appear.
3/10/2020 9:45:16 PM [NORMAL] - Shutting down language client...
3/10/2020 9:45:16 PM [NORMAL] - Language server starting --
3/10/2020 9:45:16 PM [NORMAL] - PowerShell executable: C:\Users\czachariou.dotnet\tools\pwsh.exe
3/10/2020 9:45:16 PM [NORMAL] - PowerShell args: -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command Import-Module 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Diagnostic' -LogPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\logs\1583894716-02660d03-e13b-43f8-8e43-c76d363230961583894154248\EditorServices.log' -SessionDetailsPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\sessions\PSES-VSCode-13904-869624' -FeatureFlags @()
3/10/2020 9:45:16 PM [NORMAL] - PowerShell Editor Services args: Import-Module 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Diagnostic' -LogPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\logs\1583894716-02660d03-e13b-43f8-8e43-c76d363230961583894154248\EditorServices.log' -SessionDetailsPath 'c:\Users\czachariou.vscode\extensions\ms-vscode.powershell-preview-2020.3.0\sessions\PSES-VSCode-13904-869624' -FeatureFlags @()
3/10/2020 9:45:16 PM [NORMAL] - pwsh.exe started.
3/10/2020 9:45:16 PM [NORMAL] - Waiting for session file
3/10/2020 9:47:16 PM [NORMAL] - Error occurred retrieving session file:
Timed out waiting for session file to appear.
3/10/2020 9:47:16 PM [NORMAL] - Language server startup failed.
3/10/2020 9:47:16 PM [ERROR] - The language service could not be started:
3/10/2020 9:47:16 PM [ERROR] - Timed out waiting for session file to appear.

@olyamusok
Copy link
Author

olyamusok commented Mar 12, 2020

@rjmholt apologies for delayed response, just saw the tag. Glad @soulwiper was able to test.

@soulwiper
Copy link

@TylerLeonhardt and @rjmholt and @olyamusok is there a solution found to the dilemma of not been able to debug and the language issue when using PowerShell Extention 2020.3.0?

@rjmholt
Copy link
Contributor

rjmholt commented 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
Copy link
Member

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

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Mar 17, 2020
@sqlchick
Copy link

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.)

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jun 14, 2020
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Engine Issue-Bug A bug to squash. Needs: Fix Verification Please verify the fix for us!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants