powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG] Connect-PnPOnline: Method not found: 'System.String System.String.Format(System.IFormatProvider, System.String, System. Object)'.

Open siljemda opened this issue 5 years ago • 2 comments

Reporting an Issue or Missing Feature

Unable to connect to SharePoint Online using Connect-PnPOnline. I can run this on my personal computer but am unable to do so on a Windows 2008 Server. I need to use local certificates, but I have also testet credentials and -Interactive with the same result. Also same result whether I run in x86 or x64.

Expected behavior

Connect to a specific SP site

Actual behavior

From Get-PnPException:

Message          : Method not found: 'System.String System.String.Format(System.IFormatProvider, System.String, System.
                   Object)'.
Stacktrace       :    at Microsoft.Identity.Client.AuthorityInfo..ctor(AuthorityType authorityType, String authority, B
                   oolean validateAuthority)
                      at Microsoft.Identity.Client.AbstractApplicationBuilder`1.WithAuthority(String authorityUri, Bool
                   ean validateAuthority)
                      at PnP.Framework.AuthenticationManager..ctor(String clientId, String redirectUrl, String tenantId
                   , AzureEnvironment azureEnvironment, Action`1 tokenCacheCallback, ICustomWebUi customWebUi)
                      at PnP.Framework.AuthenticationManager.CreateWithInteractiveLogin(String clientId, Action`2 openB
                   rowserCallback, String tenantId, String successMessageHtml, String failureMessageHtml, AzureEnvironm
                   ent azureEnvironment, Action`1 tokenCacheCallback)
                      at PnP.PowerShell.Commands.Base.PnPConnectionHelper.InstantiateInteractiveConnection(Uri uri, Str
                   ing clientId, String tenantAdminUrl, Boolean launchBrowser, AzureEnvironment azureEnvironment, Cance
                   llationTokenSource cancellationTokenSource, Boolean forceAuthentication)
                      at PnP.PowerShell.Commands.Base.ConnectOnline.ConnectInteractive()
                      at PnP.PowerShell.Commands.Base.ConnectOnline.Connect(CancellationToken& cancellationToken)
                      at PnP.PowerShell.Commands.Base.ConnectOnline.ProcessRecord()
                      at System.Management.Automation.CommandProcessor.ProcessRecord()
ScriptLineNumber : 1

Steps to reproduce behavior

connect-pnponline -url https://organization.sharepoint.com -Interactive

or

$conn = Connect-PnPOnline `
  -Thumbprint $CertificateThumbprint `
  -Tenant organization.onmicrosoft.com `
  -ClientId $clientId `
  -Url https://organization.sharepoint.com/sites/somesite `
  -ReturnConnection

What is the version of the Cmdlet module you are running?

1.3.0

From PSVersionTable:

Name                           Value                                                                                                                                      
----                           -----                                                                                                                                      
PSVersion                      5.1.14409.1005                                                                                                                             
PSEdition                      Desktop                                                                                                                                    
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                    
BuildVersion                   10.0.14409.1005                                                                                                                            
CLRVersion                     4.0.30319.18444                                                                                                                            
WSManStackVersion              3.0                                                                                                                                        
PSRemotingProtocolVersion      2.3                                                                                                                                        
SerializationVersion           1.1.0.1

Upon checking assembly version (from this comment by @erwinvanhunen ):

PS C:\Users\isv.sdahl> [AppDomain]::CurrentDomain.GetAssemblies() | ?{$_.Location -like "*Microsoft.SharePoint.Client.dl
l"} | %{Get-Item  $_.Location | select -ExpandProperty VersionInfo}

ProductVersion   FileVersion      FileName
--------------   -----------      --------
16.1.20912.12000 16.1.20912.12000 C:\Program Files\WindowsPowerShell\Modules\PnP.PowerShell\1.3.0\Framework\Microsof...

.NET Version 4.5.2.

Which operating system/environment are you running PnP PowerShell on?

  • [X] Windows (from Windows Server 2008 R2 Standard)
  • [ ] Linux
  • [ ] MacOS
  • [ ] Azure Cloud Shell
  • [ ] Azure Functions
  • [ ] Other : please specify

siljemda avatar Mar 01 '21 20:03 siljemda

We require at least .net 4.6.1 to be available on the machine. We cannot use 4.5.x unfortunately so the only way forward is to install a more recent version of the dotnet framework on the machine or revert to a much older build of PnP PowerShell.

erwinvanhunen avatar Mar 01 '21 20:03 erwinvanhunen

Thanks a lot, after upgrading everything works as expected.

siljemda avatar Mar 02 '21 17:03 siljemda