Better UserProfileBackup
This commit is contained in:
parent
a16bdb6b40
commit
97cd6b84fd
|
|
@ -19,7 +19,7 @@
|
||||||
'Videos'
|
'Videos'
|
||||||
'AppData\Local\Google\Chrome\User Data\Default\Bookmarks'
|
'AppData\Local\Google\Chrome\User Data\Default\Bookmarks'
|
||||||
'AppData\Roaming\Microsoft'
|
'AppData\Roaming\Microsoft'
|
||||||
'Sticky Notes'
|
# 'Sticky Notes'
|
||||||
)
|
)
|
||||||
|
|
||||||
#Creates a log file
|
#Creates a log file
|
||||||
|
|
@ -31,10 +31,10 @@
|
||||||
for ($i = 0; $i -lt $FoldersToCopy.Length; $i++) {
|
for ($i = 0; $i -lt $FoldersToCopy.Length; $i++) {
|
||||||
$Folder = $FoldersToCopy[$i]
|
$Folder = $FoldersToCopy[$i]
|
||||||
|
|
||||||
Write-Progress -Activity "User Profile Transfer from $srcPath to $dstPath" -Status $Folder -PercentComplete (($i / $FoldersToCopy.Length)*100)
|
Write-Progress -Activity "User Profile Transfer from $srcPath to $dstPath" -Status $Folder -PercentComplete (($i / $FoldersToCopy.Length)*100) -Id 0
|
||||||
|
|
||||||
$Source = Join-Path -Path $srcPath -ChildPath $Folder
|
$Source = Join-Path -Path $srcPath -ChildPath $Folder
|
||||||
$Destination = $dstPath
|
$Destination = Join-Path -Path $dstPath -ChildPath $Folder
|
||||||
Write-Host "Copying $Folder"
|
Write-Host "Copying $Folder"
|
||||||
|
|
||||||
if( $Folder -eq 'Sticky Notes'){
|
if( $Folder -eq 'Sticky Notes'){
|
||||||
|
|
@ -68,23 +68,63 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if( -not ( Test-Path -Path $Destination -PathType Container ) ){
|
if( -not ( Test-Path -Path $Destination -PathType Container ) ){
|
||||||
Write-Warning "Could not find path`t$Destination"
|
New-Item "$Destination" -ItemType Container | Write-Verbose
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($Folder -eq 'AppData\Roaming\Microsoft'){
|
if($Folder -eq 'AppData\Roaming\Microsoft'){
|
||||||
#If it's time to copy AppData folder it changes the copy destination to build the proper directory tree
|
#If it's time to copy AppData folder it changes the copy destination to build the proper directory tree
|
||||||
|
|
||||||
$Destination = Join-Path -Path $Destination -ChildPath 'AppData\Roaming\Microsoft'
|
Get-Item -Path "$Source\*" -Exclude ('Teams') | ForEach-Object {
|
||||||
|
$tmpDst = Join-Path $Destination $_.Name
|
||||||
Copy-Item -Path (Get-Item -Path "$Source\*" -Exclude ('Teams')).FullName -Destination $Destination -Recurse -Force -PassThru | Out-File $log -Append
|
if( -not ( Test-Path -Path $tmpDst -PathType Container ) ){
|
||||||
|
New-Item "$tmpDst" -ItemType Container
|
||||||
|
}
|
||||||
|
Copy-Directory $_ $tmpDst -ProgressBarIndex 1 | Out-File $log -Append
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host 'complete'
|
Write-Host 'complete'
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
Copy-Item $Source -Destination $Destination -Recurse -PassThru | Out-File $log -Append
|
Copy-Directory $Source $Destination -ProgressBarIndex 1 | Out-File $log -Append
|
||||||
Write-Host "complete"
|
Write-Host "complete"
|
||||||
}
|
}
|
||||||
Write-Progress -Activity "User Profile Transfer from $srcPath to $dstPath" -Completed
|
Write-Progress -Activity "User Profile Transfer from $srcPath to $dstPath" -Completed
|
||||||
#endregion
|
#endregion
|
||||||
}#End Function
|
}#End Function
|
||||||
|
|
||||||
|
function Copy-Directory {
|
||||||
|
param (
|
||||||
|
$SourceDir,
|
||||||
|
$DestDir,
|
||||||
|
[int]$ProgressBarIndex = 0
|
||||||
|
)
|
||||||
|
if ($ProgressBarIndex -eq 0) {
|
||||||
|
Write-Progress -Activity "Copying Directory" -Status "$SourceDir to $DestDir" -PercentComplete 0 -Id $ProgressBarIndex
|
||||||
|
} else {
|
||||||
|
Write-Progress -Activity "Copying Directory" -Status "$SourceDir to $DestDir" -PercentComplete 0 -Id $ProgressBarIndex -ParentId ($ProgressBarIndex-1)
|
||||||
|
}
|
||||||
|
# Should be 0, but this prevents divide by zero errors. Not used for logic, just progress bar, so innaccuracy is fine.
|
||||||
|
$TotalLength = 1
|
||||||
|
Get-ChildItem -Recurse $SourceDir | ForEach-Object { $TotalLength += $_.Length }
|
||||||
|
$ProgressLength = 0
|
||||||
|
Get-ChildItem $SourceDir | ForEach-Object {
|
||||||
|
Write-Progress -Activity "Copying Directory" -Status "$SourceDir to $DestDir" -Id $ProgressBarIndex -PercentComplete $($ProgressLength*100/$TotalLength)
|
||||||
|
$item = $_
|
||||||
|
$DestDirPath = Join-Path $DestDir $item.Name
|
||||||
|
switch -Regex ($item.Mode) {
|
||||||
|
'd-----' {
|
||||||
|
if (-not (Test-Path $DestDirPath)) {
|
||||||
|
New-Item -Path $DestDir -Name $item.Name -ItemType Directory | Write-Verbose
|
||||||
|
}
|
||||||
|
Copy-Directory -SourceDir $item.FullName -DestDir $DestDirPath -ProgressBarIndex $($ProgressBarIndex+1)
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
Copy-Item $item.FullName $DestDirPath -PassThru
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} | ForEach-Object {
|
||||||
|
$ProgressLength += $_.Length
|
||||||
|
$_
|
||||||
|
}
|
||||||
|
Write-Progress -Activity "Copying Directory" -Status "$SourceDir to $DestDir" -Completed -Id $ProgressBarIndex
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
Patch
|
Patch
|
||||||
-Update Custom SHSApps have more robust detection
|
-Update Custom SHSApps have more robust detection
|
||||||
-Fix SCCM queries return mac address correctly
|
-Fix SCCM queries return mac address correctly
|
||||||
|
-Update UserProfileBackup has progress bars!
|
||||||
|
-Update UserProfileBackup doesn't copy Sticky Notes anymore
|
||||||
|
-Update UserProfileBackup reports fewer non-critical errors
|
||||||
|
|
||||||
Patch 2025-4-29
|
Patch 2025-4-29
|
||||||
-Fix DEL messages from SCCM queries now use the correct hostname
|
-Fix DEL messages from SCCM queries now use the correct hostname
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue