저는 셰어 포인트 온라인 서버의 한 목록에서 다른 목록으로 항목을 복사하는 스크립트를 작성하고 있습니다. 나는 2013 쉘 포인트 Client Side Object Model (CSOM)을 사용하여 PowerShell ISE에서 이것을 스크립팅하고 있습니다. 이것은 쉬운 일이되어야하지만 그것은 정반대의 것을 증명하고 있습니다. 지금까지 필자는 camlquery를 사용하여 모든 항목을 검색 할 수 있었지만 그 항목과 첨부 파일을 다른 목록에 복사하려고했습니다.Sharepoint Online 2013 AttachmentCollection 개체의 CSOM 생성자 오류가 발생 했습니까?
이Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$siteURL = "https://mysite.sharepoint.com"
$password = Read-Host -Prompt "Enter Password" -AsSecureString
$ctx = New-Object Microsoft.Sharepoint.Client.ClientContext($siteURL)
$credentials = New-Object Microsoft.Sharepoint.Client.SharepointOnlineCredentials("[email protected]", $password)
$ctx.Credentials = $credentials
#...Bunch of code that establishes/loads web/lists/items, all works fine
function CopyItem $itemToCopy
function CopyItem ($oldItem)
{
Write-Host "Copying item" $oldItem.ID
$newItemCI = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
$newItem = $archList.AddItem($newItemCI)
$ctx.load($newItem)
#Update fields
$ctx.load($sourceList.Fields)
$ctx.ExecuteQuery()
foreach($field in $sourceList.Fields)
{
$newItem[$field.InternalName] = $oldItem[$field.InternalName]
}
$attachments = New-Object Microsoft.SharePoint.Client.AttachmentCollection #ERROR HERE
$attachments = $oldItem.AttachmentFiles
$ctx.load($attachments)
$newItem.AttachmentFiles.Add($attachments)
$newItem.Update()
$ctx.load($newItem)
$ctx.ExecuteQuery()
}
오류 메시지가 말한다 : "리스트 아카이브가 실패 I 나타나는 오류는 모든 항목에서 모든 첨부 파일을 검색하는 attachmentCollection을 설정하려고 시도에서이다, 여기에 문제를 나타내는 스크립트의 일부입니다 at :이 오류 메시지와 함께 : 생성자를 찾을 수 없습니다. Microsoft.SharePoint.Client.AttachmentCollection 유형의 적절한 생성자를 찾을 수 없습니다. "
첨부 파일로 새 개체를 만들려고해도 동일한 오류가 발생하며 생성자를 찾을 수 없습니다. 이것은 생성자가 client.dll에 있어야하지만 운이 없으므로 이상합니다. 심지어 2013 CSOM 파일을 복구하려고 시도했지만 오류가 발견되지 않았습니다. 어떤 도움이라도 고맙습니다. 감사합니다.