Session log: BirthBiologic Datto-to-SharePoint migration

Supply Management migrated (160 files), SPMT launched for 4 remaining
folders, Syncro ticket #109277420 opened, SPB license assigned to
sysadmin. Script, errors, SP site map, and next steps documented.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 17:59:37 -07:00
parent 48f1b4b612
commit a9bcbc2580
2 changed files with 151 additions and 5 deletions

View File

@@ -50,7 +50,8 @@ param(
[string]$DattoRoot = "C:\Users\Public\Desktop\Datto Workplace Server Projects",
[string]$OnlyFolder = "",
[switch]$WhatIf,
[bool]$Resume = $true
[bool]$Resume = $true,
[switch]$DeltaOnly
)
$ErrorActionPreference = "Stop"
@@ -206,6 +207,10 @@ function Upload-LargeFile {
$fileSize = (Get-Item $LocalPath).Length
$encoded = Encode-Path $RemotePath
# Delete any existing/partial item first so upload session creation doesn't 409
$deleteUri = "${GRAPH_ROOT}/sites/${SiteId}/drive/root:/${encoded}"
try { Invoke-Graph -Method DELETE -Uri $deleteUri | Out-Null } catch {}
$sessionUri = "${GRAPH_ROOT}/sites/${SiteId}/drive/root:/${encoded}:/createUploadSession"
$sessionBody = '{"item":{"@microsoft.graph.conflictBehavior":"replace"}}'
$session = Invoke-Graph -Method POST -Uri $sessionUri -Body $sessionBody
@@ -241,6 +246,10 @@ function Upload-LargeFile {
}
$offset += $read
}
} catch {
# Cancel the upload session so outer retries can start a fresh one
try { Invoke-RestMethod -Method DELETE -Uri $uploadUrl -ErrorAction SilentlyContinue } catch {}
throw
} finally {
$stream.Dispose()
Write-Host ""
@@ -289,6 +298,24 @@ function Migrate-Folder {
$sizeMB = [math]::Round($file.Length / 1MB, 2)
Write-Log " [$($done + $skip + $fail + 1)/$total] $relPath ($sizeMB MB)"
if ($DeltaOnly) {
# Check if SharePoint already has this file and it's current
$encoded = Encode-Path $remotePath
$checkUri = "${GRAPH_ROOT}/sites/${SiteId}/drive/root:/${encoded}?select=lastModifiedDateTime,size"
try {
$spItem = Invoke-Graph -Method GET -Uri $checkUri
$spDate = [datetime]$spItem.lastModifiedDateTime
$localDate = $file.LastWriteTimeUtc
if ($spItem.size -gt 0 -and $spDate -ge $localDate) {
$skip++
continue
}
Write-Log " [DELTA] $relPath (SP: $($spDate.ToString('yyyy-MM-dd')) / Local: $($localDate.ToString('yyyy-MM-dd')))"
} catch {
# Not found in SP — upload it
}
}
if ($WhatIf) {
Write-Log " [WHATIF] -> $remotePath"
$done++
@@ -325,7 +352,7 @@ function Migrate-Folder {
# Main
Write-Log "=== BirthBiologic Datto -> SharePoint Migration ==="
Write-Log "Source: $DattoRoot"
Write-Log "WhatIf=$WhatIf | Resume=$Resume | OnlyFolder=$(if ($OnlyFolder) { $OnlyFolder } else { '(all)' })"
Write-Log "WhatIf=$WhatIf | Resume=$Resume | DeltaOnly=$DeltaOnly | OnlyFolder=$(if ($OnlyFolder) { $OnlyFolder } else { '(all)' })"
if (-not (Test-Path $DattoRoot)) {
Write-Log "ERROR: Datto root not found: $DattoRoot" "ERROR"