system_configuration/capture.ps1

36 lines
1.2 KiB
PowerShell
Raw Permalink Normal View History

2023-03-20 03:57:16 -07:00
$path = $PSScriptRoot
Write-Host "Capturing files begin"
$rootCaptureFolder = Join-Path -Path $path -ChildPath "root"
if (-not (Test-Path -Path $rootCaptureFolder)) {
Write-Host "Could not find [$rootCaptureFolder]"
return
}
2023-03-20 04:00:16 -07:00
$captureListFile = Join-Path -Path $path -ChildPath "capture.filelist"
2023-03-20 03:57:16 -07:00
$fileList = Get-Content -Path $captureListFile
foreach ($file in $fileList) {
2023-04-15 01:27:31 -07:00
if ([string]::IsNullOrWhiteSpace($file)) { continue }
2023-03-20 03:57:16 -07:00
$files = @()
if ($file.IndexOf('/*') -gt -1) {
2023-04-15 01:45:47 -07:00
$files += Get-ChildItem -Path $file -Recurse -Attributes Hidden,System,Normal
2023-03-20 03:57:16 -07:00
} else {
2023-04-15 01:45:47 -07:00
$files += Get-ChildItem -Path $file -Attributes Hidden,System,Normal
2023-03-20 03:57:16 -07:00
}
foreach ($file in $files) {
Write-Host "Found $($file.FullName)"
$targetCopy = Join-Path $rootCaptureFolder -ChildPath $file.FullName
$targetParent = Split-Path -Path $targetCopy -Parent
if (-not (Test-Path -Path $targetParent)) {
New-Item -ItemType Directory -Path $targetParent -Force | Out-Null
}
2023-04-15 01:22:57 -07:00
Write-Host "Copy-Item -Path '$($file.FullName)' -Destination '$($targetParent)'"
Copy-Item -Path $file.FullName -Destination $targetParent
2023-03-20 03:57:16 -07:00
}
}
2023-03-30 02:15:51 -07:00
chown go:go ./* -R