You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: scripts/spo-compare-files/README.md
+119-2Lines changed: 119 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,11 @@
4
4
5
5
## Summary
6
6
7
-
This script first connects to the first tenant using the Connect-PnPOnline cmdlet, then uses the Get-PnPFile cmdlet to retrieve the file in question. It then connects to the second tenant and retrieves the same file. The script then uses the Get-FileHash cmdlet to retrieve the hash of the file in both tenants. Finally, it compares the hashes of the two files and outputs the results to the console.
7
+
This script compares files from two different SharePoint tenants by calculating and comparing their hash values. This is useful for verifying file integrity after migrations or ensuring files are identical across tenants. This sample is available in both PnP PowerShell and CLI for Microsoft 365.
8
8
9
+
Example of script output of the CLI for Microsoft 365 version:
10
+
11
+

9
12
10
13
# [PnP PowerShell](#tab/pnpps)
11
14
@@ -32,13 +35,127 @@ if ($hash1 -eq $hash2) {
32
35
33
36
```
34
37
[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)]
38
+
39
+
# [CLI for Microsoft 365](#tab/cli-m365-ps)
40
+
41
+
```powershell
42
+
[CmdletBinding()]
43
+
param(
44
+
[Parameter(Mandatory, HelpMessage = "URL of the site in first tenant")]
45
+
[string]$WebUrl1,
46
+
47
+
[Parameter(Mandatory, HelpMessage = "Server-relative URL of the file in first tenant")]
48
+
[string]$FileUrl1,
49
+
50
+
[Parameter(Mandatory, HelpMessage = "URL of the site in second tenant")]
51
+
[string]$WebUrl2,
52
+
53
+
[Parameter(HelpMessage = "Server-relative URL of the file in second tenant (defaults to same as FileUrl1)")]
54
+
[string]$FileUrl2,
55
+
56
+
[Parameter(HelpMessage = "Name for the first tenant connection (defaults to 'tenant1')")]
57
+
[string]$Connection1Name = "tenant1",
58
+
59
+
[Parameter(HelpMessage = "Name for the second tenant connection (defaults to 'tenant2')")]
60
+
[string]$Connection2Name = "tenant2"
61
+
)
62
+
63
+
begin {
64
+
if ([string]::IsNullOrEmpty($FileUrl2)) {
65
+
$FileUrl2 = $FileUrl1
66
+
}
67
+
68
+
Write-Host "Setting up connections to both tenants..." -ForegroundColor Cyan
69
+
70
+
Write-Host "Logging in to first tenant ($WebUrl1)..." -ForegroundColor Cyan
71
+
m365 login --connectionName $Connection1Name
72
+
if ($LASTEXITCODE -ne 0) {
73
+
throw "Failed to login to first tenant"
74
+
}
75
+
76
+
Write-Host "Logging in to second tenant ($WebUrl2)..." -ForegroundColor Cyan
0 commit comments