Giter VIP home page Giter VIP logo

powershell-user-backup-restore-script's Introduction

PowerShell User Data Backup & Restore Scripts

When I came into my current role in Desktop Support, we were using BATCH scripts to perform these tasks. However, I wanted to move them to PowerShell.

My goals for creating this were:

  1. Keep the process simple
  2. Provide seamless transition for my team
  3. Backup and Restore the same information as before

What does the script backup and restore:

  1. All user data (Desktop, Documents, Downloads, Favorites, Pictures)
  2. Browser data from Google Chrome and Firefox
  3. Network printer information and Mapped Network drives

Code snippet:

#region DeclaringDataBackupSources
$folder = "Desktop",
  "Downloads",
  "Favorites",
  "Documents",
  "Pictures",
  "AppData\Local\Google\Chrome\User Data",
  "AppData\Local\Mozilla\Firefox\Profiles",
  "AppData\Roaming\Mozilla\Firefox"
#endregion DeclaringDataBackupSources

What's been added

I added a little piece to the backup script to clear all browser cache to allow the backup time to decrease.

Here is a snippet of that code:

##region CacheFolderDeletion Variables (Currently supports Chrome and Firefox)
$delete = "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Cache\",
  "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Code Cache\",
  "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Service Worker\ScriptCache",
  "$env:LOCALAPPDATA\Google\Chrome\User Data\Profile 1\Cache\",
  "$env:LOCALAPPDATA\Google\Chrome\User Data\Profile 1\Code Cache\",
  "$env:LOCALAPPDATA\Google\Chrome\User Data\Profile 1\Service Worker\ScriptCache",
  "$env:LOCALAPPDATA\Mozilla\Firefox\Profiles\*.default\cache",
  "$env:LOCALAPPDATA\Mozilla\Firefox\Profiles\*.default\cache2"
##endregion CacheFolderDeletion Variables

##region DeleteFiles
Write-Host -ForegroundColor Cyan "Begin Browser Cleanup"
Get-ChildItem -Path $delete | Remove-Item -Verbose -Recurse
##endregion

The script has been tested on Windows 7 and Windows 10 and is 100% working.

Variables to setup

For the Backup script:

$destination

For the Restore script:

$source

Please feel free to use and modify the script to suit your needs.

powershell-user-backup-restore-script's People

Contributors

aaronzercher avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.