Untitled

mail@pastecode.io avatar
unknown
powershell
a month ago
932 B
2
Indexable
Never
cd c:\
$browser_profile = "browser_profile_$(Get-Date -Format 'yyyy-MM-dd_HHmm')"
mkdir $browser_profile
Get-ChildItem -Path C:\Users -Directory | ForEach-Object {
  $username = $_.Name
  $user_data = @(
    "\AppData\Local\Google\Chrome\User Data",
    "\AppData\Local\Microsoft\Edge\User Data",
    "\AppData\Local\Mozilla\Firefox\Profiles"
  )
  $user_data | ForEach-Object {
    Get-ChildItem -Path "C:\Users\${username}$_" -Directory -ErrorAction Ignore | ForEach-Object {
      if ($_.Name -ceq "Default" -or
          $_.Name -like "Profile *" -or
          $_.FullName -like "*\Firefox\Profiles\*") {
        echo "Copying: $($_.FullName)"
        cp -Recurse -ErrorAction Ignore "$($_.FullName)" `
          "${browser_profile}\${username}\$($_.Parent.Parent.Name)\$($_.Name)"
      }
    }
  }
}
Compress-Archive $browser_profile "${browser_profile}.zip"
Remove-Item $browser_profile -Force -Recurse
Leave a Comment