C# 连接到SharePoint时解决Shell问题
任何人都可以在此提供帮助:C# 连接到SharePoint时解决Shell问题,c#,asp.net,powershell,C#,Asp.net,Powershell,任何人都可以在此提供帮助: Add-Type –Path "C:\Users\chauda31\SharePointDLL\Microsoft.SharePoint.Client.dll" Add-Type –Path "C:\Users\chauda31\SharePointDLL\Microsoft.SharePoint.Client.Runtime.dll" #Mysite URL $site = 'https://triasdasdadcaplc.sharepoint.com/sit
Add-Type –Path "C:\Users\chauda31\SharePointDLL\Microsoft.SharePoint.Client.dll"
Add-Type –Path "C:\Users\chauda31\SharePointDLL\Microsoft.SharePoint.Client.Runtime.dll"
#Mysite URL
$site = 'https://triasdasdadcaplc.sharepoint.com/sites/ServadfficeDeliveryDashboard/'
#Admin User Principal Name
$admin = 'arvind.chaudhary@cedsfsfcxznt.com'
#Get Password as secure String
$password = Read-Host 'Enter Password' -AsSecureString
#Get the Client Context and Bind the Site Collection
$context = New-Object Microsoft.SharePoint.Client.ClientContext($site)
#Authenticate
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($admin , $password)
$context.Credentials = $credentials
$list = $context.Web.Lists.GetByTitle('Daily Status')
$context.Load($list)
#$list.Description = "CSOM PowerShell - Did it!!!"
$list.Update()
$context.ExecuteQuery()
错误:
新对象:找不到类型
[Microsoft.SharePoint.Client.SharePointOnlineCredentials]:验证
已加载包含此类型的程序集。在
C:\Users\chauda31\OneDrive-Centrica\Documents\SharePointPS.ps1:18
字符:16
+ ... edentials=新对象Microsoft.SharePoint.Client.SharePointOnlineCr。。。
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:InvalidType:(:)[New Object],pArgumentException
+FullyQualifiedErrorId:TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
任何人都可以在此提供帮助。加载程序集时似乎存在问题。你能检查一下这两个dll的路径是否正确吗?是的,我检查过了,dll是否正确。你试过用不同的方式加载它们吗?像使用
[System.Reflection.Assembly]::LoadFile
。你可以看看博客,也许你可以更接近解决方案。