简体   繁体   English

Sharepoint 在线 - MoveFile - pnp.powershell 状态更新

[英]Sharepoint online - MoveFile - pnp.powershell Status Updates

I'm trying to do folder/files moves from one sharepoint site to another, and I can't seem to get the Receive-PnPCopyMoveJobStatus to work in my powershell script我正在尝试将文件夹/文件从一个共享点站点移动到另一个共享点站点,但似乎无法在我的 powershell 脚本中使用 Receive-PnPCopyMoveJobStatus

Right now the only way I can monitor a file/folder move is to monitor the source's recycling bin for changes.现在,我可以监视文件/文件夹移动的唯一方法是监视源的回收站的更改。 I'd like to be able to get progress either on demand, or consistently in an open powershell.我希望能够按需或始终在开放的 powershell 中取得进展。 Ideally I'd like to see a percentage sign, and even a verbose option.理想情况下,我希望看到一个百分比符号,甚至是一个详细的选项。

Here's what I have put together:以下是我整理的内容:

#Config Variables
$SiteURL = "https://<site>.sharepoint.com/
$SourceFolderURL= "sites/<site name>/<document library name>/<Folder or file location>"
$TargetFolderURL = "sites/<site name>/<document library name>"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -interactive

#Sharepoint Copy/Move operation feedback
$Test = "Move-PnPFile -SourceUrl $SourceFolderURL -TargetUrl $TargetFolderURL -Overwrite -noWait"
$jobStatus = "Receive-PnPCopyMoveJobStatus -Job $Test"

if($jobStatus.JobState -eq 0)
{
  Write-Host "Job finished"
}

referencing: https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/receive-pnpcopymovejobstatus?view=sharepoint-ps参考: https : //docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/receive-pnpcopymovejobstatus?view=sharepoint-ps

I haven't been successful in running this.我没有成功运行这个。 When I fill in the site names, library names, and actual site, I get a result that looks like it completes, but with no feedback, nor do the files move.当我填写站点名称、库名称和实际站点时,我得到的结果看起来已经完成,但没有反馈,文件也没有移动。 So essentially nothing happens.所以基本上什么也没发生。

What does work for the file/folder move is the following:文件/文件夹移动的作用如下:

#Config Variables
$SiteURL = "https://<site>.sharepoint.com/"
$SourceFolderURL= "sites/<site name>/<document library>/<folder name>"
$TargetFolderURL = "sites/<site name>/<document library>"
 
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -interactive
 
#sharepoint online powershell move folder
Move-PnPFile -SourceUrl $SourceFolderURL -TargetUrl $TargetFolderURL -overwrite 


#Read more: https://www.sharepointdiary.com/2017/06/how-to-move-folder-in-sharepoint-online.html#ixzz7Bkp822M1

Any help on correcting this script, or other methods on seeing the progress of Copy or Move operations on SharePoint would be appreciated!任何有关更正此脚本的帮助,或查看 SharePoint 上复制或移动操作进度的其他方法,将不胜感激!

The source url should be like "<document library>/<file name>" Please try following script源 url 应该类似于"<document library>/<file name>"请尝试以下脚本

$SiteURL = "https://<site>.sharepoint.com/sites/<sitesname>
$SourceFolderURL= "<document library name>/<file name>"
$TargetFolderURL = "<document library name>/<target file name>"

$job = Move-PnPFile -SiteRelativeUrl $SourceFolderURL -TargetUrl $TargetFolderURL -Overwrite
$jobStatus = Receive-PnPCopyMoveJobStatus -Job $result
if($jobStatus.JobState == 0)
{
  Write-Host "Job finished"
}

Your non-working script contains:您的非工作脚本包含:

$Test = "Move-PnPFile -SourceUrl $SourceFolderURL -TargetUrl $TargetFolderURL -Overwrite -noWait"
$jobStatus = "Receive-PnPCopyMoveJobStatus -Job $Test"

Both of these variable values are strings.这两个变量值都是字符串。 They don't do anything except exist, and do not cause any commands to run.它们除了存在之外什么都不做,并且不会导致任何命令运行。 $jobStatus.JobState will always be null and never zero, because JobState is not a property of a string, so the if condition is never met. $jobStatus.JobState将始终为 null 并且永远不会为零,因为 JobState 不是字符串的属性,因此永远不会满足 if 条件。

If you want to run the commands, don't write them as strings inside double quotes, but just as they are in the documentation you referred to.如果您想运行这些命令,请不要将它们写为双引号内的字符串,而要像您所引用的文档中的那样。 You can actually run them, and capture their output, with eg您实际上可以运行它们,并捕获它们的输出,例如

$jobStatus = Receive-PnPCopyMoveJobStatus -Job $Test

You can also just copy and paste the example and update the parameter values (though it seems to have the wrong variable name on the second line, which you've already fixed).您也可以复制并粘贴示例并更新参数值(尽管第二行的变量名称似乎有误,但您已修复)。 You may have further errors once the commands are running, which should provide further diagnostic information.命令运行后,您可能会遇到更多错误,这应该会提供更多诊断信息。 Make sure that you are doing all of connecting, requesting the move, and retrieving the status information in the same script.确保您在同一脚本中执行所有连接、请求移动和检索状态信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Powershell(选项 1 - 使用 PnP.Powershell)将文件上传到 Sharepoint Online (Microsoft 365) - Upload file to Sharepoint Online (Microsoft 365) using Powershell (Option 1-Using PnP.Powershell) 使用 Pnp.PowerShell 新建 ListItem - New ListItem with Pnp.PowerShell 新 Sharepoint 模块 PnP.PowerShell 中缺少 Apply-PnPProvisioningTemplate cmdlet - Missing Apply-PnPProvisioningTemplate cmdlet in new Sharepoint module PnP.PowerShell 新的 PnP.PowerShell 模块出现问题 - Trouble with the new PnP.PowerShell module Powershell PnP - 在线登录 Sharepoint 并下载文件 - Powershell PnP - login to Sharepoint online and download file PNP powershell SharePoint Online 设置新式页面 bannerimageurl - PNP powershell SharePoint Online set modern page bannerimageurl SharePoint OnLine - PowerShell PNP - 列出具有属性的文件夹 - SharePoint OnLine - PowerShell PNP - List folders that have attribute 使用 pnp 更新 SharePoint 在线文档库列属性 PowerShell - update SharePoint online document library column property using pnp PowerShell 使用PnP PowerShell for SharePoint Online在文档库上设置“说明” - Setting the “Description” on a Document Library using PnP PowerShell for SharePoint Online 需要使用 PnP 在线 SharePoint 中添加语言翻译器 PowerShell - Need to Add Translators for Language in SharePoint Online using PnP PowerShell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM