This is one of the posts from the PoweshellIT series in which we get common and sometimes not so common usecases and try to simplify/automate them using PowerShell.
Today’s Use Case
Perform a backup/migration of files from any laptop to a network drive. copy all files/folders of the user to their new computer. It needs to be able to migrate over printers, stored WiFi connections and browser passwords and settings.
Infrastructure overview

Disclaimer: In this post we are only backing up the data. It do not include next logical step which would be restoring user profiles and settings.
Context
Not a super complicated task, we just need to make sure that we will cover all of the items mentioned in the use case description. We have 4 main categories:
- User Profile Files – all files from user profile folder;
User profile files are stored in C:\Users\<username> folder. We need to copy all files within the user profile directory.
- Printers – list of printers added to the computer;
Get list of printers, drivers, ports etc. Basically all of the available properties for each and every printer connected to the computer.
Reference: Get-Printer cmdlet.
- WiFi Networks – list of saved WiFi networks and passwords;
Get list of all saved WiFi networks including the passwords. Idea is to use built in netsh tool.
Reference: Get Wireless Network SSID and Password with PowerShell
- Browser Profiles – web browser profiles.
Copy web browser profile files. Due to huge variety of different web browsers available we will focus on 2 most popular ones: Mozilla Firefox and Google Chrome.
Input will be username of the user we would like to copy data for.
Challenges
- Within the user profile folder there are a lot files which are some cache and temporary application files. That’s why we will exclude whole AppData folder
- On the other hand web browser profiles (for Mozilla and Chrome) are stored in App Data folder and we will need to get and copy them accordingly
- Process should be modular. There should be a possibility to copy all data or just desired one like Printers only or WiFiNetworks and BrowserProfiles.
Proposed solution
Simple and elegant PowerShell function which will accept username Destination where to copy user’s data.
Pseudo code
Get Username and Data to Copy and Destination Path if DataToCopy contains "Files" Get user profile files Copy to Destination Path if DataToCopy contains "Printers" Get list of printers Export to Destination Path if DataToCopy contains "WiFiNetworks" Get list of save WiFi networks and passwords Export to Destination Path if DataToCopy contains "BrowserProfiles" Get Firefox profile files Copy to Destination Path Get Chrome profile files Copy to Destination Path End.
It has been wrapped into PowerShell module called BackupUserProfile.
Module contains one function called Copy-UserProfile.
Copy-UserProfile
Copy User profile files to desired destination. Supported data and settings:
- User Profile Files – all files from user profile folder. AppData folder is excluded by default
- Printers – list of printers added to the computer
- WiFi Networks – list of saved wifi networks and passwords.
- Browser Profiles – web browser profiles.
EXAMPLE
Copy-UserProfile -UserName test2 -Data2Copy All -DestinationPath C:\MigrationDestination\

All of the source code is available in PowerShellIT repository on the GitHub.
Thanks a lot for reading.

Icons made by Eucalyp & Good Ware & Freepik from www.flaticon.com