minor updates

This commit is contained in:
2024-02-23 17:05:49 -05:00
parent 401cc3ded1
commit 497126d138
+16 -20
View File
@@ -17,7 +17,12 @@ Function Add-UserProfilePaths {
# Iterate over each $profilePath and join it with the supplied $Path # Iterate over each $profilePath and join it with the supplied $Path
ForEach ( $profilePath in $UserProfilePaths ) { ForEach ( $profilePath in $UserProfilePaths ) {
Update-ListOfPaths -List $List -Path $(Join-Path -Path $profilePath -ChildPath $($Path -split '%')[2])
# Build the path we're trying to add
$path = $(Join-Path -Path $profilePath -ChildPath $($Path -split '%')[2])
# Only add the path if it exists (domain computers may have many invalid/old user accounts with nonexistant paths)
If ( Test-Path $path ) { Update-ListOfPaths -List $List -Path $path }
} }
} }
@@ -36,9 +41,15 @@ Import-MSP360Module
# Get all backup plans # Get all backup plans
$BackupPlans = Get-MBSBackupPlan -OutputType Raw $BackupPlans = Get-MBSBackupPlan -OutputType Raw
# Track the number of processed backup plans so we can put line breaks between them in the output
$planIter = 0
# Iterate over all backup plans # Iterate over all backup plans
ForEach ( $plan in $BackupPlans ) { ForEach ( $plan in $BackupPlans ) {
# Add a line break in the output if we've already processed a backup plan
If ( $planIter -gt 0 ) { Write-Output "`n" }
# Function to process each file # Function to process each file
Function ProcessFile { Function ProcessFile {
param([System.IO.FileInfo]$File) param([System.IO.FileInfo]$File)
@@ -73,7 +84,7 @@ ForEach ( $plan in $BackupPlans ) {
[System.Collections.Hashtable]$FilteredFiles = @{} [System.Collections.Hashtable]$FilteredFiles = @{}
[System.Collections.Hashtable]$IncludedFiles = @{} [System.Collections.Hashtable]$IncludedFiles = @{}
# Get all included items from older plan format # Get all included items from plan
If ( $null -ne $plan.Items ) { If ( $null -ne $plan.Items ) {
ForEach ( $obj in $plan.Items ) { ForEach ( $obj in $plan.Items ) {
ForEach ( $path in $obj.PlanItem.Path ) { ForEach ( $path in $obj.PlanItem.Path ) {
@@ -81,14 +92,8 @@ ForEach ( $plan in $BackupPlans ) {
} }
} }
} }
## Get all included items from newer plan format
#If ( $null -ne $plan.BackupItem ) {
# ForEach ( $path in $plan.BackupItem ) {
# Use-Path -List $IncludedPaths -Path $path
# }
#}
# Get all excluded items from older plan format # Get all excluded items from plan
If ( $null -ne $plan.ExcludedItems ) { If ( $null -ne $plan.ExcludedItems ) {
ForEach ( $obj in $plan.ExcludedItems ) { ForEach ( $obj in $plan.ExcludedItems ) {
ForEach ( $path in $obj.PlanItem.Path ) { ForEach ( $path in $obj.PlanItem.Path ) {
@@ -97,20 +102,13 @@ ForEach ( $plan in $BackupPlans ) {
} }
} }
## Get all excluded items from newer plan format
#If ( $null -ne $plan.ExcludeItem ) {
# ForEach ( $path in $plan.ExcludeItem ) {
# Use-Path -List $ExcludedPaths -Path $path
# }
#}
# Print all paths in $IncludedPaths # Print all paths in $IncludedPaths
If ( $IncludedPaths.Length -gt 0 ) { If ( $IncludedPaths.Length -gt 0 ) {
Write-Output "Paths to backup:" Write-Output "Paths to backup:"
ForEach ( $path in ($IncludedPaths | Sort-Object) ) { Write-Output $path } ForEach ( $path in ($IncludedPaths | Sort-Object) ) { Write-Output $path }
} }
# Define $MaxFileSize if it exists, or set it to the max value of a long to bypass it # Define $MaxFileSize if it exists, or set it to the default value if it can't be obtained
If ( $null -ne $plan.MaxFileSize ) { $MaxFileSize = $plan.MaxFileSize } Else { $MaxFileSize = [long]::MaxValue } If ( $null -ne $plan.MaxFileSize ) { $MaxFileSize = $plan.MaxFileSize } Else { $MaxFileSize = [long]::MaxValue }
# Process each path in $IncludedPaths # Process each path in $IncludedPaths
@@ -150,7 +148,5 @@ ForEach ( $plan in $BackupPlans ) {
Write-Output $file.Name Write-Output $file.Name
} }
} }
$planIter++
# Print a newline after each plan
Write-Output "`n"
} }