Skip to content
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

Cannot make it work in powershell 5.1 #41

Closed
pavel242242 opened this issue Jun 27, 2018 · 14 comments

Comments

Projects
None yet
7 participants
@pavel242242
Copy link

commented Jun 27, 2018

Maybe, I'm not getting it correctly, so feel free to blame me, but...

Install-Module -name MicrosoftPowerBIMgmt # works like a charm

Import-Module -name MicrosoftPowerBIMgmt or just simply running Connect-PowerBIServiceAccount or anything else ends up with:
_Import-Module : Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT:
0x80131058)
At line:1 char:1

  • Import-Module -Name MicrosoftPowerBIMgmt.Profile
  •   + CategoryInfo          : NotSpecified: (:) [Import-Module], BadImageFormatException
      + FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.ImportModuleCommand_
    
    

get-host
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse
returns:

_Name : Windows PowerShell ISE Host
Version : 5.1.15063.1088
InstanceId : 1026cdab-d162-42ee-839f-ab276e926a30
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.Host.ISE.ISEOptions
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace

PSChildName : v2.0.50727
Version : 2.0.50727.4927
Release :
PSChildName : v3.0
Version : 3.0.30729.4926
Release :
PSChildName : Windows Communication Foundation
Version : 3.0.4506.4926
Release :
PSChildName : Windows Presentation Foundation
Version : 3.0.6920.4902
Release :
PSChildName : v3.5
Version : 3.5.30729.4926
Release :
PSChildName : Client
Version : 4.7.02046
Release : 460798
PSChildName : Full
Version : 4.7.02046
Release : 460798
PSChildName : Client
Version : 4.0.0.0
Release :_

I've tried installing dotnet core 2.1, 2.1 SDK included the path to the netstandard.dll in path, with no luck.

I must be missing something.

Oh, I was kind of missing something "[Future release]". So it works in powershell core 6.0.2 (but no luck in 5.1.15063.1088), maybe the powerbi-powershell is only for powershell core 6.

Thanks

@CodeCyclone

This comment has been minimized.

Copy link
Collaborator

commented Jun 27, 2018

It should work on PowerShell 5.1 with .NET Framework 4.6.1, currently it doesn't work on PowerShell Core due to the Power BI SDK package which uses AutoRest and ClientRuntime which target .NET Standard 1.4 instead of .NET Standard 2.0 causing it to fall back to .NET Framework 4.6.1. When that is fixed, it will work on both Windows PowerShell 3.0+ with .NET 4.6.1+ and PowerShell Core 6.0+.

I'm deploying a clean machine to reproduce the issue. If I'm unable to, I will reply back with instructions to enable FusionLog to gather logs about which file it is failing to load. We try to bundle all dependencies into the module so errors like this don't happen. The dependencies are discovered automatically during the build\compile phase, we may have a gap where something indirectly is leveraged breaking the dependency graph.

@CodeCyclone CodeCyclone self-assigned this Jun 27, 2018

@CodeCyclone CodeCyclone added the bug label Jun 27, 2018

@CodeCyclone

This comment has been minimized.

Copy link
Collaborator

commented Jun 27, 2018

Hi @pavel242242 I wasn't able to reproduce the error on a clean Windows 10 environment. Can you do the following so I can get logs?

In a PowerShell administrator prompt run the following:

$LogPath = "$env:SystemDrive\FusionLog"
[void](New-Item -Path $LogPath -ItemType Directory -ErrorAction SilentlyContinue)
Set-ItemProperty -Path $script:fusionPath -Name ForceLog -Value 1 -Type DWord
Set-ItemProperty -Path $script:fusionPath -Name LogFailures -Value 1 -Type DWord
Set-ItemProperty -Path $script:fusionPath -Name LogResourceBinds -Value 1 -Type DWord
Set-ItemProperty -Path $script:fusionPath -Name LogPath -Value $LogPath -Type String

The above enables FusionLog to collect errors, then call:

Connect-PowerBIServiceAccount

You should see the error in the console again and you should get logs dropped to c:\FusionLog, zip them up and attach to issue.

To disable Fusion log run:

Remove-ItemProperty -Path $fusionPath -Name ForceLog
Remove-ItemProperty -Path $fusionPath -Name LogFailures
Remove-ItemProperty -Path $fusionPath -Name LogResourceBinds
Remove-ItemProperty -Path $fusionPath -Name LogPath

I will dig through the logs and find out which assembly is missing.
Thanks!

@CodeCyclone

This comment has been minimized.

Copy link
Collaborator

commented Jul 13, 2018

Hi @pavel242242 were you able to reproduce the issue and gather logs?
I will close this issue next week if I don't get a response, hopefully you were able to load the cmdlets successfully.

@pavel242242

This comment has been minimized.

Copy link
Author

commented Jul 13, 2018

@w00dbury

This comment has been minimized.

Copy link

commented Jul 24, 2018

I got the same thing on Server 2016.

Fusion.zip

@janelhunt

This comment has been minimized.

Copy link

commented Jul 25, 2018

FusionLogs.zip
I also confirm that on a Windows 10 pc with .Net Framework 4.7.02053 and Powershell Version 5.1, that I seemed to be able to Install MicrosoftPowerBIMgmt Module, but on running Connect-PowerBIServiceAccount I get the following error, the same as above:

Connect-PowerBIServiceAccount : The 'Connect-PowerBIServiceAccount' command was found in the module 'MicrosoftPowerBIMgmt.Profile', but the module could not be
loaded. For more information, run 'Import-Module MicrosoftPowerBIMgmt.Profile'.
At line:1 char:1

  • Connect-PowerBIServiceAccount
  •   + CategoryInfo          : ObjectNotFound: (Connect-PowerBIServiceAccount:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
    
    

and on running Import-Module MicrosoftPowerBIMgmt.Profile, I get this error message:

Import-Module : Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.
Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
At line:1 char:1

  • Import-Module MicrosoftPowerBIMgmt.Profile
  •   + CategoryInfo          : NotSpecified: (:) [Import-Module], BadImageFormatException
      + FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.ImportModuleCommand
    
    

I tried to run Fusion Log to capture the errors, but unfortunately I could not get it to work.

I have now got Fusion working. Attached is the Fusion zip file.

@jkirch01

This comment has been minimized.

Copy link

commented Jul 26, 2018

I get the same error. Windows 7, PowerShell 5.1

@fishnexj

This comment has been minimized.

Copy link

commented Aug 1, 2018

I am also receiving this error:

Import-Module : Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Reference assemblies should not be loaded for execution.  They can only be loaded in the 
Reflection-only loader context. (Exception from HRESULT: 0x80131058)

System Specs:
Windows 10 Enterprise (v1702, OS Build 15063.1209)
PowerShell version: 5.1.15063.1209

get-host
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse

returns:

Name             : Windows PowerShell ISE Host
Version          : 5.1.15063.1209
InstanceId       : b35cfc0c-cf77-4f62-8ddb-1bc2782e0d7a
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.Host.ISE.ISEOptions
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Property      : {}
PSPath        : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\CDF
PSParentPath  : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
PSChildName   : CDF
PSDrive       : HKLM
PSProvider    : Microsoft.PowerShell.Core\Registry
PSIsContainer : True
SubKeyCount   : 1
View          : Default
Handle        : Microsoft.Win32.SafeHandles.SafeRegistryHandle
ValueCount    : 0
Name          : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\CDF

Property      : {HttpNamespaceReservationInstalled, NetTcpPortSharingInstalled, NonHttpActivationInstalled, SMSvcHostPath...}
PSPath        : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\CDF\v4.0
PSParentPath  : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\CDF
PSChildName   : v4.0
PSDrive       : HKLM
PSProvider    : Microsoft.PowerShell.Core\Registry
PSIsContainer : True
SubKeyCount   : 0
View          : Default
Handle        : Microsoft.Win32.SafeHandles.SafeRegistryHandle
ValueCount    : 5
Name          : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\CDF\v4.0

Property      : {CBS, Increment, Install, OCM...}
PSPath        : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727
PSParentPath  : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
PSChildName   : v2.0.50727
PSDrive       : HKLM
PSProvider    : Microsoft.PowerShell.Core\Registry
PSIsContainer : True
SubKeyCount   : 23
View          : Default
Handle        : Microsoft.Win32.SafeHandles.SafeRegistryHandle
ValueCount    : 6
Name          : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727

Property      : {Install, MSI, OCM}
PSPath        : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727\1028
PSParentPath  : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727
PSChildName   : 1028
PSDrive       : HKLM
PSProvider    : Microsoft.PowerShell.Core\Registry
@fishnexj

This comment has been minimized.

Copy link

commented Aug 1, 2018

@CodeCyclone I attempted to generate Fushion logs as well, but run into the following null variable error:

[void](New-Item -Path $LogPath -ItemType Directory -ErrorAction SilentlyContinue)
Set-ItemProperty -Path $script:fusionPath -Name ForceLog -Value 1 -Type DWord
Set-ItemProperty -Path $script:fusionPath -Name LogFailures -Value 1 -Type DWord
Set-ItemProperty -Path $script:fusionPath -Name LogResourceBinds -Value 1 -Type DWord
Set-ItemProperty -Path $script:fusionPath -Name LogPath -Value $LogPath -Type String
C:\Users\j837115\Desktop\FusionLog
Set-ItemProperty : Cannot bind argument to parameter 'Path' because it is null.
At line:9 char:24
+ Set-ItemProperty -Path $script:fusionPath -Name ForceLog -Value 1 -Ty ...
+                        ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Set-ItemProperty], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetItemPropertyCommand

What is $script:fusionPath intended to return?

@SQLIO

This comment has been minimized.

Copy link

commented Aug 14, 2018

stefvsignup solved this issue for me... download and install the .net framework

@janelhunt

This comment has been minimized.

Copy link

commented Aug 14, 2018

I already had the .net framework installed and still receive the same error message as initially reported on this bug. The versions of software on my PC all seem to be supported, according to the documentation, Set up of as follows:

Windows 10 Education Version 1607 OS Build 14393.1884
.Net Framework 4.7.02053
Powershell Version 5.1 Build 14393 Revision 1884
MicrosoftPowerBIMgmt Modules Version 1.0.295

I attached the Fusion logs zip file to my initial comment which hopefully will help trace the reason for the error.

I notice that this error is also reported in the power bi community developer forum
https://community.powerbi.com/t5/Developer/Unable-to-Connect-with-Power-BI-Service-using-PowerShell/m-p/483356

The Community Support Team there suggested that the ExecutionPolicy needed to be changed. This did not make any difference, however, even when set to unrestricted.

@janelhunt

This comment has been minimized.

Copy link

commented Aug 14, 2018

Update - I installed .net Framework 4.7.2 and I can now run the Power BI cmdlets!

@fishnexj

This comment has been minimized.

Copy link

commented Aug 23, 2018

Great news! Installing .NET Framework 4.7.2 worked for me as well! The Power BI cmdlets work like a charm now.

@CodeCyclone CodeCyclone referenced this issue Sep 5, 2018

Merged

Merging Dev #78

CodeCyclone added a commit that referenced this issue Sep 5, 2018

Merge pull request #78 from Microsoft/dev
- Fixes netstandard issue commented on in issues #60, #63, #41 (note: this doesn't fix Newtonsoft.Json conflicts mentioned in #60 ArrayTypeMismatchException)

- Fix for issue #62 casting column objects by @kenakamu

- New Data cmdlets for Add-PowerBIDataset, Add-PowerBIRow, Get-PowerBITable, New-PowerBIColumn, New-PowerBITable, Remove-PowerBIRow, and Set-PowerBITable by @kenakamu

- General Doc fixes

- Internal improvements
@CodeCyclone

This comment has been minimized.

Copy link
Collaborator

commented Sep 6, 2018

Should be fixed in https://www.powershellgallery.com/packages/MicrosoftPowerBIMgmt/1.0.326. You shouldn't need 4.7.2 (still need at least 4.6.1) but if you already have 4.7.2 then the issue is already avoided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.