尝试使用具有PowerShell Azure功能的Connect-PnPOnline连接到Office 365时,出现异常

时间:2019-05-29 23:31:40

标签: function azure authentication office365

当尝试使用带有PowerShell Azure功能的Connect-PnPOnline连接到Office 365时,出现异常,而在本地计算机上执行此操作则正常。

$ securepw = ConvertTo-SecureString $ env:PW -AsPlainText -Force $ credentials =新对象System.Management.Automation.PSCredential($ env:USER,$ securepw) $ spo =“ https://.sharepoint.com/sites/tt” Connect-PnPOnline -Url $ spo -Credentials $ credentials

-     使用最新版本      显式导入PnP-PowerShell cmdlet

Import-Module 

“ D:\ home \ site \ wwwroot \ modules \ SharePointPnPPowerShellOnline \ 3.9.1905.3 \ SharePointPnPPowerShellOnline.psd1”-详细

-     例外:

2019-05-29T23:09:27.958 [Error] ERROR: Method not found: 'System.Runtime.Remoting.ObjectHandle System.Activator.CreateInstance(System.String, System.String)'.
Microsoft.Azure.WebJobs.Script.Rpc.RpcException : Result: ERROR: Method not found: 'System.Runtime.Remoting.ObjectHandle System.Activator.CreateInstance(System.String, System.String)'.
Exception: Method not found: 'System.Runtime.Remoting.ObjectHandle System.Activator.CreateInstance(System.String, System.String)'.
Stack:    at OfficeDevPnP.Core.Diagnostics.Log.InitializeLogger()
   at OfficeDevPnP.Core.Diagnostics.Log.Error(String source, String message, Object[] args)
   at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay, String userAgent)
   at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryRetry(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay, String userAgent)
   at SharePointPnP.PowerShell.Commands.Base.SPOnlineConnectionHelper.InstantiateSPOnlineConnection(Uri url, PSCredential credentials, PSHost host, Boolean currentCredentials, Int32 minimalHealthScore, Int32 retryCount, Int32 retryWait, Int32 requestTimeout, String tenantAdminUrl, Boolean disableTelemetry, Boolean skipAdminCheck, ClientAuthenticationMode authenticationMode)
   at SharePointPnP.PowerShell.Commands.Base.ConnectOnline.ProcessRecord()
   at System.Management.Automation.Cmdlet.DoProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()

参考文献:

  1. 我正在尝试申请以下博客: http://johnliu.net/blog/2018/4/run-any-pnp-powershell-in-one-azurefunction-from-microsoft-flow

  2. 在我看来,这个例外最近发生在其他人身上。 https://twitter.com/erwinvanhunen/status/1095413544810627074

0 个答案:

没有答案