2016-06-28 10 views
0

私はこの質問を以前に一度聞いたことがありますが、少し間違いがありました。もう一度:Powershellを使用したフォルダ構造からチームサイトへ

私はPowershellを使用してSPOのチームサイトのドキュメントライブラリに自分のPC上にあるフォルダのフォルダ構造を統合しようとしています。

$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 $_ 
} 

が、私は「書き込みホスト」とフォルダを表示することができていると私はまた、フォルダの権限を持っているが、私はそれをアップロードすることはできません:私は、チームサイトを作成した後、私は次のスクリプトを使用します。各フォルダとサブフォルダに次のエラーメッセージが表示されます。

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 

私は誰かが間違っていると教えてくれることを願っています。 SharePoint Onlineの(.ContentStreamパラメータを省略)にフォルダを追加する方法

事前のおかげで、多くの挨拶

アンディ

+1

'Test-Path $ _。FullName'は動作していますか? –

+0

いいえ動作していません.. Test-Path:引数がNULLなので、引数 "Path"にバインドすることはできません。ラインで :1文字:11 +テストパス$ _フルネーム + ~~~~~~~~~~~ + CategoryInfo:InvalidData:(:) [テストパス]、ParameterBindingValidationException + FullyQualifiedErrorId。 ParameterArgumentValidationErrorNullNotAllowed、Microsoft.PowerShell.Commands.TestPathCommand – andyohn

+0

単なるフォルダの場合、.ContentStreamを追加する理由はありますか? – grisha

答えて

0

$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() 

から:Copy folder structure from one list to another in a different site collection

ますTechnet Galleryの他のスクリプトもチェックできます:copy folder

関連する問題