0

以前にも一度質問したのですが、少し間違いがありました。もう一度:

PC にあるフォルダーのフォルダー構造を、Powershell を使用して SPO 上のチーム サイトのドキュメント ライブラリに統合しようとしています。チーム サイトを作成した後、次のスクリプトを使用します。

$Folder = "D:\Skripte\04_Manuelle_Ausfuehrung\Office 365\CreateSite\Teamseiten"
$DocLibName = "Dokumente"

#Retrieve list
$List = $ctx.Web.Lists.GetByTitle($DocLibName)
$ctx.Load($List)
$ctx.ExecuteQuery()


#Upload file
Get-ChildItem -Recurse $Folder | 
Foreach-Object {
$FileStream = New-Object IO.FileStream($_.FullName,[System.IO.FileMode]::Open)
$FileCreationInfo = New-Object Microsoft.SharePoint.Client.FileCreationInformation
$FileCreationInfo.Overwrite = $true
$FileCreationInfo.ContentStream = $FileStream
$FileCreationInfo.URL = $_
$Upload = $List.RootFolder.Files.Add($FileCreationInfo)
$ctx.Load($Upload)
$ctx.ExecuteQuery()
Write-Host $_
}

「Write-Host」でフォルダの表示はできており、フォルダの権限もあるのですが、アップロードできません。各フォルダーとサブフォルダーに次のエラー メッセージが表示されます。

New-Object: Exception calling ".ctor" with 2 argument (s): "Access to the path" D:\scripts\04_Manuelle_Ausfuehrung\Office 365\Createsite\Team Sites\01_Bekanntmachung and guidelines "
was denied."
In D:\scripts\04_Manuelle_Ausfuehrung\Office 365\Createsite\SPOCreateSite.ps1: 84 mark: 15
+ $FileStream = New-Object IO.FileStream ($_.FullName, [System.IO.FileMode] :: Open)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
    + Category Info: InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId: ConstructorInvokedThrowException, Microsoft.PowerShell.Commands.NewObjectCommand

Exception calling "executeQuery" with 0 Argument (s): "parameters.Content, parameters.ContentStream
Parameter name: The specified value is not supported parameters.ContentStream parameters for parameters.Content ".
In D:\scripts\04_Manuelle_Ausfuehrung\Office 365\Createsite\SPOCreateSite.ps1: 91 mark: 1
+ $Ctx.ExecuteQuery ()
+ ~~~~~~~~~~~~~~~~~~~
    + Category Info: NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId: ServerException

誰かが何が悪いのか教えてくれることを願っています。

事前に感謝し、多くの挨拶

アンディ

4

1 に答える 1

0

SharePoint Online にフォルダーを追加する方法 (.ContentStream パラメーターを省略):

$lici =New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
$lici.UnderlyingObjectType=[Microsoft.SharePoint.Client.FileSystemObjectType]::Folder
$lici.LeafName=$urel2
$newFolder=$ll2.AddItem($lici)#$ll2.RootFolder.ServerRelativeUrl, [Microsoft.SharePoint.Client.FileSystemObjectType]::Folder)
$ctx2.Load($newFolder)
$newFolder.Update()
$ctx2.ExecuteQuery()
$newFolder["Title"]="Your title"
$newFolder.Update()
$ctx2.ExecuteQuery()

差出人:あるリストから別のサイト コレクション内の別のリストにフォルダー構造をコピーする

Technet Gallery から他のスクリプトも確認できます: copy folder

于 2016-07-11T06:08:38.000 に答える