forked from Zerg00s/FlowPowerAppsMigrator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompleteResourceMapping.ps1
More file actions
39 lines (33 loc) · 1.31 KB
/
CompleteResourceMapping.ps1
File metadata and controls
39 lines (33 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[CmdletBinding()]
param (
[Parameter(Mandatory = $false)]
[switch]$DoNotReconnect
)
if ($null -eq $TARGET_SITE_URL) {
$TARGET_SITE_URL = Read-Host "Enter the URL of the destination SharePoint site"
}
if($DoNotReconnect.IsPresent -eq $false){
Connect-PnPOnline -Url $TARGET_SITE_URL -UseWebLogin -WarningAction Ignore
}
$lists = Get-PnPList -Includes Views, Fields, DefaultView
$lists = $lists | Where-Object hidden -eq $false
$resources = Import-Csv -Path .\resourceMapping.csv
$resources[0].newId = $TARGET_SITE_URL
$lists | ForEach-Object {
$line = "" | Select-Object resource, oldId, newId
$line.resource = $_.RootFolder.ServerRelativeUrl.Replace($_.ParentWebUrl, "")
$line.newId = $_.ID
$resource = $resources | Where-Object resource -eq $line.resource
if ($resource -ne $null) {
$resource.newId = $line.newId
}
$line = "" | Select-Object resource, oldId, newId
$line.resource = $_.DefaultView.ServerRelativeUrl.Replace($_.ParentWebUrl, "")
$line.newId = $_.DefaultView.ID
$resource = $resources | Where-Object resource -eq $line.resource
if ($resource -ne $null) {
$resource.newId = $line.newId
}
}
$resources | Export-Csv -Path "resourceMapping.csv" -NoTypeInformation
Write-Host Mapping file resourceMapping.csv fully complete -ForegroundColor Green