将文件从本地传输到在线共享点
Transfer File from on prem to sharepoint online
我正在使用带有以下脚本的 Sharepoint 在线 pnp 处理文件传输脚本
#Set up variables to fetch data
$SiteURL = "https://demo.sharepoint.com/sites/ssup"
$TargetFolderURL = "/Shared Documents/FileDemo/FilesFromX"
$FilestoLoadToSPO = Get-ChildItem -Path \Demo_FileTransfer\FilesToSPO -Filter '*.txt'
#results with listing 2 files.
#Connect to PnP Online
Connect-PnPOnline -Url $siteurl -UseWebLogin
Foreach ($file in $FilestoLoadToSPO ) {
Add-PnPFile -Path $file -Folder $TargetFolderURL
}
我收到以下错误。任何帮助将不胜感激。
Add-PnPFile : Local file was not found.
At line:14 char:5
+ Add-PnPFile -Path $file -Folder $TargetFolderURL
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Add-PnPFile], FileNotFoundException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Files.AddFile
Add-PnPFile : Local file was not found.
At line:14 char:5
+ Add-PnPFile -Path $file -Folder $TargetFolderURL
+ CategoryInfo : WriteError: (:) [Add-PnPFile], FileNotFoundException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Files.AddFile
Get-ChildItem returns 对象,不是路径。如果将 $file
传递给 Add-PnPFile,它将被转换为字符串,但结果将只是文件名,而不是完整路径。 (自己试试:$file.ToString()
)
使用 FullName
属性 指定完整路径,如下所示:
Add-PnPFile -Path $file.FullName -Folder $TargetFolderURL
我正在使用带有以下脚本的 Sharepoint 在线 pnp 处理文件传输脚本
#Set up variables to fetch data
$SiteURL = "https://demo.sharepoint.com/sites/ssup"
$TargetFolderURL = "/Shared Documents/FileDemo/FilesFromX"
$FilestoLoadToSPO = Get-ChildItem -Path \Demo_FileTransfer\FilesToSPO -Filter '*.txt'
#results with listing 2 files.
#Connect to PnP Online
Connect-PnPOnline -Url $siteurl -UseWebLogin
Foreach ($file in $FilestoLoadToSPO ) {
Add-PnPFile -Path $file -Folder $TargetFolderURL
}
我收到以下错误。任何帮助将不胜感激。
Add-PnPFile : Local file was not found.
At line:14 char:5
+ Add-PnPFile -Path $file -Folder $TargetFolderURL
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Add-PnPFile], FileNotFoundException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Files.AddFile
Add-PnPFile : Local file was not found.
At line:14 char:5
+ Add-PnPFile -Path $file -Folder $TargetFolderURL
+ CategoryInfo : WriteError: (:) [Add-PnPFile], FileNotFoundException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Files.AddFile
Get-ChildItem returns 对象,不是路径。如果将 $file
传递给 Add-PnPFile,它将被转换为字符串,但结果将只是文件名,而不是完整路径。 (自己试试:$file.ToString()
)
使用 FullName
属性 指定完整路径,如下所示:
Add-PnPFile -Path $file.FullName -Folder $TargetFolderURL