capture.ps1 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. $path = $PSScriptRoot
  2. Write-Host "Capturing files begin"
  3. $rootCaptureFolder = Join-Path -Path $path -ChildPath "root"
  4. if (-not (Test-Path -Path $rootCaptureFolder)) {
  5. Write-Host "Could not find [$rootCaptureFolder]"
  6. return
  7. }
  8. $captureListFile = Join-Path -Path $path -ChildPath "capture.filelist"
  9. $fileList = Get-Content -Path $captureListFile
  10. foreach ($file in $fileList) {
  11. if ([string]::IsNullOrWhiteSpace($file)) { continue }
  12. $files = @()
  13. if ($file.IndexOf('/*') -gt -1) {
  14. $files += Get-ChildItem -Path $file -Recurse -Attributes Hidden,System,Normal
  15. } else {
  16. $files += Get-ChildItem -Path $file -Attributes Hidden,System,Normal
  17. }
  18. foreach ($file in $files) {
  19. Write-Host "Found $($file.FullName)"
  20. $targetCopy = Join-Path $rootCaptureFolder -ChildPath $file.FullName
  21. $targetParent = Split-Path -Path $targetCopy -Parent
  22. if (-not (Test-Path -Path $targetParent)) {
  23. New-Item -ItemType Directory -Path $targetParent -Force | Out-Null
  24. }
  25. Write-Host "Copy-Item -Path '$($file.FullName)' -Destination '$($targetParent)'"
  26. Copy-Item -Path $file.FullName -Destination $targetParent
  27. }
  28. }
  29. chown go:go ./* -R