通过


使用 PowerShell 将 SharePoint Server 工作流迁移到 Power Automate

Microsoft 于 2020 年 11 月 1 日从现有租户中删除了 SharePoint Server 2010 工作流服务。 建议将经典 SharePoint Server 工作流迁移到 Power Automate 流。

现在可以迁移:

  • SharePoint Server 2010 开箱即用 (OOTB) 审批并向 Power Automate 收集反馈工作流。
  • 列表和库的“开箱即用”(OOTB) 审批工作流
  • 工作流定义和关联

注意

当前不支持 SharePoint Designer 或 SharePoint Server 2013 创建的工作流。

注意

若要使用 SPMT 迁移工作流,请参阅 使用 SPMT 将 SharePoint Server 2010 工作流迁移到 Power Automate

准备工作

在开始工作流迁移之前,必须先:

  • 配置所需的终结点。
  • 配置 Power Automate。 如果之前从未对此租户使用过 Power Automate,则必须在开始迁移之前对其进行配置。 我们建议使用 Edge 或 Internet Explorer。

有关详细步骤,请参阅:

扫描工作流

此命令扫描给定站点或列表的工作流并生成扫描报告。


Register-SPMTMigration -ScanOnly $true -SPOCredential $targetCredential -UserMappingFile $userMappingFile -MigrationType WORKFLOW -DefaultFlowOwnerEmail  $defaultOwnerName -Force
...
Start-SPMTMigration

迁移工作流

此命令执行以下操作:

  • 迁移网站或列表的工作流
  • 生成迁移包
  • 将包导入 Power Automate 和
  • 生成迁移报告。

MigrationType

当 MigrationType 为 WORKFLOW 时,如果尚未迁移结构,则该命令将迁移站点或列表结构(非内容),然后迁移其工作流。

DefaultFlowOwnerEmail

OOTB 审批工作流需要默认流所有者,因为工作流定义中没有任何所有者。 迁移后,只有流所有者和 Power Automate 管理员才能访问迁移的流。 如果给定的所有者电子邮件不是目标位置的有效用户,则迁移将失败。 流所有者还需要具有访问目标 SPO 列表的权限。


> Register-SPMTMigration -SPOCredential $targetCredential -UserMappingFile $userMappingFile -MigrationType WORKFLOW -DefaultFlowOwnerEmail $defaultOwnerName -Force
...
Start-SPMTMigration

示例 PowerShell 脚本


Import-Module "$((Resolve-Path .\).Path)\Microsoft.SharePoint.MigrationTool.PowerShell.dll"

clear
Remove-Variable * -ErrorAction SilentlyContinue

$currentFolder = (Resolve-Path .\).Path
$userMappingFile = "$($currentFolder)\Sample-UserMap.csv"
$defaultOwnerName = "please enter flow owner email here"

$targetSite = "please enter destination site URL here"
$targetUserName = "please enter destination site admin user email here"
$targetPassWord = ConvertTo-SecureString -String "please enter destination user password here" -AsPlainText -Force 
$targetCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $targetUserName, $targetPassWord

Register-SPMTMigration -SPOCredential $targetCredential -UserMappingFile $userMappingFile -IgnoreUpdate -MigrationType WORKFLOW -DefaultFlowOwnerEmail $defaultOwnerName -Force

$sourceSite = "please enter source site URL here"
$sourceUsername = "please enter source site admin username here"
$sourcePassword = ConvertTo-SecureString -String "please enter destination user password here" -AsPlainText -Force
$sourceCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $sourceUsername, $sourcePassword
Add-SPMTTask -SharePointSourceCredential $sourcecredential -SharePointSourceSiteUrl $sourceSite -TargetSiteUrl $targetSite `
#-SourceList "please enter source list name here" -TargetList "please enter destination list name here"

Write-Host "Start migration"
$StartTime = [DateTime]::UtcNow

# Let the migration run in background using NoShow mode
Start-SPMTMigration

$migration = Get-SPMTMigration

# open report folder
start $migration.ReportFolderPath