Skip to content

Issue running cmdltes from MicrosoftPowerBIMgmt Module #2397

Closed
PowerShell/PowerShellEditorServices
#1227

Description

@olyamusok

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

  1. ghost added
    Needs: Triage
    on Jan 2, 2020
  2. rjmholt commented on Jan 2, 2020

    @rjmholt
    Contributor

    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?

  3. olyamusok commented on Jan 3, 2020

    @olyamusok
    Author

    Rob Holt (@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
    
    
  4. rjmholt commented on Jan 3, 2020

    @rjmholt
    Contributor

    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.

  5. rjmholt commented on Jan 3, 2020

    @rjmholt
    Contributor

    I'll continue playing with the .NET Framework solution to see if there's a possible solution, but I'm not optimistic.

  6. olyamusok commented on Jan 6, 2020

    @olyamusok
    Author

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

  7. added
    Issue-Bug
    Needs: Fix Verification
    and removed
    Needs: Triage
    on Jan 7, 2020
  8. SydneyhSmith commented on Mar 5, 2020

    @SydneyhSmith
    Collaborator

    Closing as PS7 is now GA

  9. 4 remaining items

  10. TylerLeonhardt commented on Mar 10, 2020

    @TylerLeonhardt
    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

  11. rjmholt commented on Mar 10, 2020

    @rjmholt
    Contributor

    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.

  12. olyamusok commented on Mar 12, 2020

    @olyamusok
    Author

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

  13. rjmholt commented on Mar 12, 2020

    @rjmholt
    Contributor

    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

  14. TylerLeonhardt commented on Mar 13, 2020

    @TylerLeonhardt
    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

  15. sqlchick commented on Jun 14, 2020

    @sqlchick

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

  16. ghost added
    Needs: Maintainer Attention
    on Jun 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area-EngineIssue-BugNeeds: Fix Verification

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions