-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to migrate lists and libraries
- Loading branch information
Showing
9 changed files
with
270 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,8 @@ resourceMapping.csv | |
settings.json | ||
/temp | ||
/dist | ||
/samples | ||
/samples | ||
/package | ||
/FlowPowerAppsMigrator | ||
Lists.xml | ||
*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@ECHO OFF | ||
PowerShell.exe -Command "& '.\Convert-Packages.ps1' -path '%~dp0'" | ||
PAUSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
param ( | ||
[string]$Path | ||
) | ||
# Created by Denis Molodtsov (@Zerg00s) in 2018 | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
$host.UI.RawUI.WindowTitle = "Flow & Power Apps Migrator" | ||
|
||
Write-host | ||
Write-host | ||
Write-Host " ______ _ _____ " -ForegroundColor Yellow | ||
Write-Host " | ____| | ___ | __ \ " -ForegroundColor Yellow | ||
Write-Host " | |__ | | _____ __ ( _ ) | |__) |____ _____ _ __ " -ForegroundColor Yellow | ||
Write-Host " | __| | |/ _ \ \ /\ / / / _ \/\ | ___/ _ \ \ /\ / / _ \ `'__| " -ForegroundColor Yellow | ||
Write-Host " | | | | (_) \ V V / | (_> < | | | (_) \ V V / __/ | " -ForegroundColor Yellow | ||
Write-Host " |_| |_|\___/ \_/\_/ \___/\/_|_| \___/ \_/\_/ \___|_| " -ForegroundColor Yellow | ||
Write-Host " /\ | \/ (_) | | " -ForegroundColor Cyan | ||
Write-Host " / \ _ __ _ __ ___ | \ / |_ __ _ _ __ __ _| |_ ___ _ __ " -ForegroundColor Cyan | ||
Write-Host " / /\ \ | `'_ \| `'_ \/ __| | |\/| | |/ _`` | `'__/ _`` | __/ _ \| `'__|" -ForegroundColor Cyan | ||
Write-Host " / ____ \| |_) | |_) \__ \ | | | | | (_| | | | (_| | || (_) | | " -ForegroundColor Cyan | ||
Write-Host " /_/ \_\ .__/| .__/|___/ |_| |_|_|\__, |_| \__,_|\__\___/|_| " -ForegroundColor Cyan | ||
Write-Host " | | | | __/ | " -ForegroundColor Cyan | ||
Write-Host " |_| |_| |___/ " -ForegroundColor Cyan | ||
Write-host | ||
Write-host "-----------------------------------------------------------------------------" | ||
Write-host | ||
|
||
|
||
Set-Location $Path | ||
. .\MISC\PS-Forms.ps1 | ||
|
||
Get-ChildItem -Recurse | Unblock-File | ||
# Legacy PowerShell PnP Module is used because the new one has a critical bug | ||
Import-Module (Get-ChildItem -Recurse -Filter "*.psd1").FullName -DisableNameChecking | ||
|
||
$Migration = @{ | ||
TARGET_SITE_URL = "https://contoso.sharepoint.com/sites/Site_b" | ||
} | ||
|
||
$Migration = Get-FormItemProperties -item $Migration -dialogTitle "Enter target site" -propertiesOrder @("TARGET_SITE_URL") | ||
$TARGET_SITE_URL = $Migration.TARGET_SITE_URL | ||
|
||
Connect-PnPOnline -Url $TARGET_SITE_URL -UseWebLogin -WarningAction Ignore | ||
$xmlFiles = Get-ChildItem *.xml | ||
if($xmlFiles.Count -ne 0){ | ||
. .\MISC\Move-Lists.ps1 -Path $Path -MigrationType Import -TargetSite $TARGET_SITE_URL | ||
} | ||
. .\CompleteResourceMapping.ps1 -DoNotReconnect | ||
. .\ConvertPackage.ps1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter()] | ||
[string]$Path, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[ValidateSet('Export', 'Import')] | ||
[string]$MigrationType, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[string]$SourceSite, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[string]$TargetSite | ||
) | ||
|
||
|
||
#----------------------------------------------------------------------- | ||
# Script lets you migrate one or more SharePoint lists from source site | ||
# To destination site | ||
# Denis Molodtsov, 2021 | ||
#----------------------------------------------------------------------- | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
Clear-Host | ||
|
||
Write-Host $Path -ForegroundColor Green | ||
|
||
Set-Location $Path | ||
. .\MISC\PS-Forms.ps1 | ||
|
||
Get-ChildItem -Recurse | Unblock-File | ||
# Legacy PowerShell PnP Module is used because the new one has a critical bug | ||
Import-Module (Get-ChildItem -Recurse -Filter "*.psd1").FullName -DisableNameChecking | ||
|
||
if ($MigrationType -eq "Export") { | ||
Get-ChildItem *.xml | ForEach-Object { Remove-Item -Path $_.FullName } | ||
Get-ChildItem *.json | ForEach-Object { Remove-Item -Path $_.FullName } | ||
$lists = Get-PnPList | ||
$lists = $lists | Where-Object { $_.Hidden -eq $false } | ||
|
||
$selectedLists = Get-FormArrayItems ($lists) -dialogTitle "Select lists and libraries to migrate" -key Title | ||
$titles = $selectedLists.Title | ||
Get-pnpProvisioningTemplate -ListsToExtract $titles -Out "Lists.xml" -Handlers Lists -Force -WarningAction Ignore | ||
((Get-Content -path Lists.xml -Raw) -replace 'RootSite', 'Web') | Set-Content -Path Lists.xml | ||
foreach ($title in $titles) { | ||
# Get the latest list item form layout. Footer, Header and the Body: | ||
$list = Get-PnPList $title -Includes ContentTypes | ||
$contentType = $list.ContentTypes | Where-Object { $_.Name -eq "Item" } | ||
$contentType.ClientFormCustomFormatter | Set-Content .\$title.json | ||
} | ||
} | ||
|
||
if ($MigrationType -eq "Import") { | ||
Apply-PnPProvisioningTemplate -Path Lists.xml | ||
$jsonFiles = Get-ChildItem *.json | ||
if ($jsonFiles) { | ||
$titles = $jsonFiles | ForEach-Object { "$($_.BaseName)" } | ||
|
||
foreach ($title in $titles) { | ||
$list = Get-PnPList $title -Includes ContentTypes | ||
$contentType = $list.ContentTypes | Where-Object { $_.Name -eq "Item" } | ||
if ($contentType) { | ||
$json = Get-Content .\$title.json | ||
$contentType.ClientFormCustomFormatter = $json | ||
$contentType.Update($false) | ||
$contentType.Context.ExecuteQuery(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@ECHO OFF | ||
PowerShell.exe -Command "& '.\Prepare-Deployment-Package-for-Client.ps1' -path '%~dp0'" | ||
PAUSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
param ( | ||
[string]$Path | ||
) | ||
# Created by Denis Molodtsov (@Zerg00s) in 2018 | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
$host.UI.RawUI.WindowTitle = "Flow & Power Apps Migrator" | ||
|
||
Write-host | ||
Write-host | ||
Write-Host " ______ _ _____ " -ForegroundColor Yellow | ||
Write-Host " | ____| | ___ | __ \ " -ForegroundColor Yellow | ||
Write-Host " | |__ | | _____ __ ( _ ) | |__) |____ _____ _ __ " -ForegroundColor Yellow | ||
Write-Host " | __| | |/ _ \ \ /\ / / / _ \/\ | ___/ _ \ \ /\ / / _ \ `'__| " -ForegroundColor Yellow | ||
Write-Host " | | | | (_) \ V V / | (_> < | | | (_) \ V V / __/ | " -ForegroundColor Yellow | ||
Write-Host " |_| |_|\___/ \_/\_/ \___/\/_|_| \___/ \_/\_/ \___|_| " -ForegroundColor Yellow | ||
Write-Host " /\ | \/ (_) | | " -ForegroundColor Cyan | ||
Write-Host " / \ _ __ _ __ ___ | \ / |_ __ _ _ __ __ _| |_ ___ _ __ " -ForegroundColor Cyan | ||
Write-Host " / /\ \ | `'_ \| `'_ \/ __| | |\/| | |/ _`` | `'__/ _`` | __/ _ \| `'__|" -ForegroundColor Cyan | ||
Write-Host " / ____ \| |_) | |_) \__ \ | | | | | (_| | | | (_| | || (_) | | " -ForegroundColor Cyan | ||
Write-Host " /_/ \_\ .__/| .__/|___/ |_| |_|_|\__, |_| \__,_|\__\___/|_| " -ForegroundColor Cyan | ||
Write-Host " | | | | __/ | " -ForegroundColor Cyan | ||
Write-Host " |_| |_| |___/ " -ForegroundColor Cyan | ||
Write-host | ||
Write-host "-----------------------------------------------------------------------------" | ||
Write-host | ||
|
||
Write-Host "This script will produce a sharable package that your Client or Partner can use for deployments" -ForegroundColor Yellow | ||
|
||
Set-Location $Path | ||
. .\MISC\PS-Forms.ps1 | ||
|
||
Get-ChildItem -Recurse | Unblock-File | ||
# Legacy PowerShell PnP Module is used because the new one has a critical bug | ||
Import-Module (Get-ChildItem -Recurse -Filter "*.psd1").FullName -DisableNameChecking | ||
|
||
$Migration = @{ | ||
SOURCE_SITE_URL = "https://contoso.sharepoint.com/sites/Site_A" | ||
MIGRATE_LISTS = $true | ||
} | ||
|
||
$Migration = Get-FormItemProperties ` | ||
-item $Migration ` | ||
-dialogTitle "Enter source site URL" ` | ||
-propertiesOrder @("SOURCE_SITE_URL", "MIGRATE_LISTS") | ||
|
||
$SOURCE_SITE_URL = $Migration.SOURCE_SITE_URL | ||
if ($Migration.MIGRATE_LISTS -like "true" -or | ||
$Migration.MIGRATE_LISTS -like "yes" -or | ||
$Migration.MIGRATE_LISTS -like "1" | ||
) { | ||
$Migration.MIGRATE_LISTS = $true | ||
} | ||
else { | ||
$Migration.MIGRATE_LISTS = $false | ||
} | ||
$MIGRATE_LISTS = $Migration.MIGRATE_LISTS | ||
|
||
|
||
# Preparing package for the client | ||
New-Item -ItemType Directory -Force -Path "package" | Out-Null | ||
. .\GenerateInitialMapping.ps1 -DestinationFolder ".\package" | ||
if ($MIGRATE_LISTS) { | ||
. .\MISC\Move-Lists.ps1 -Path $Path -MigrationType Export -SourceSite $SOURCE_SITE_URL | ||
} | ||
|
||
if ((Test-Path -Path "package\MISC") -eq $false) { | ||
New-Item -ItemType Directory -Force -Path "package\src" | Out-Null | ||
New-Item -ItemType Directory -Force -Path "package\MISC" | Out-Null | ||
Copy-Item -Path "MISC\SharePointPnPPowerShellOnline" -Destination "package\MISC" -Recurse | ||
Copy-Item -Path "MISC\PS-Forms.ps1" -Destination "package\MISC" | ||
Copy-Item -Path "MISC\Move-Lists.ps1" -Destination "package\MISC" | ||
Copy-Item -Path "MISC\Convert-Packages.ps1" -Destination "package" | ||
Copy-Item -Path "MISC\Convert-Packages.bat" -Destination "package" | ||
Copy-Item -Path "Lists.xml" -Destination "package" | ||
|
||
Get-ChildItem *.json | ForEach-Object { | ||
Copy-Item -Path $_.Name -Destination "package" | ||
} | ||
|
||
Copy-Item -Path "ConvertPackage.ps1" -Destination "package" | ||
Copy-Item -Path "CompleteResourceMapping.ps1" -Destination "package" | ||
} | ||
|
||
Write-host '[Important] Next steps' -ForegroundColor Yellow | ||
Write-host "1) Export your Power Apps And Flows" -ForegroundColor Yellow | ||
Write-host "2) Place all of these exported ZIP files to the package\src folder" -ForegroundColor Yellow | ||
Write-host "3) Share the package directory with your Client or Partner" -ForegroundColor Yellow | ||
Write-host "4) Instruct your Client or Partner to run Convert-Packages.bat on their end" -ForegroundColor Yellow | ||
Write-host "5) Instruct your Client or Partner deploy all converted Apps and Flows from \dist directory" -ForegroundColor Yellow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters