Forum Discussion
Powershell Script to move Profile, Mapped Drives, Printers, and Files
I'm trying to find some example scripts to migrate Windows 10 user profiles to a new computer, but haven't had any luck with my searches. I just started a new job and have about 60 desktops to swap for employees. The new systems are ready for the domain, but I would like to have a script that helps migrate drive mappings, local and network printers, bookmarks, and files to either a network drive or USB-attached storage. I just want the process to be seamless for me and the users.
I may need to write some other code to identify and log installed software and ip addresses. (since some clients may have static ips that need DHCP records updated to reflect their new MAC address).
I don't have a lot of experience with this kind of thing because I was always using PS for AD/Exchange administration. All systems will be running Windows 10 this round. Is it possible to just copy the entire Users directory to the new PC or does that cause issues? (I've never tried it and don't have time to run into issues during the migration)
You can migrate a lot of things, but certain things could/should be configured in the domain.
- Drive mappings should be set using Group Policy or login scripts, Homedirectory can be mapped in the account settings of the user in Active Directory
- Printers can be added by the user themselves using Add Printer, Search and you could configure a Group Policy to automatically select Active Directory published printers. It's just a search and double-click action for the user to select and add the printer
- Bookmarks can be in the user profile within the browser (Google Chome or Edge)
- You could use MDT in combination with User State Migration tool (https://docs.microsoft.com/en-us/windows/deployment/usmt/getting-started-with-the-user-state-migration-tool) to backup the user profile and restore it while imaging new machines?
Inventory of the applications is something you could do with scripting (Something like https://social.technet.microsoft.com/wiki/contents/articles/54279.how-to-create-a-software-inventory-report-using-powershell-step-by-step.aspx). For the DHCP reservations you can inventory the old computer names and let the new computers receive a DHCP lease and convert it to a reservation using the old ip-address (Remove the previous reservation just before that moment)- Ryan0000Copper ContributorI agree...configuring things from the domain would be nice. I'm not currently a domain admin, but am the office admin of about 55 workstations + laptops for those folks. The drive mappings are going to a server I control permissions to... I have already worked out the script that handles the mappings.
I really just need to find a way to migrate bookmarks/favorites/etc in web browsers if I can write a script to do that.Ryan0000 I made a copy script for that, replace d:\backup with your own path. h:\backup is h:\ is the homedirectory of the user, you could run it during login using a Group Policy User Logon Script or similar.
Backup:
#Google Chrome Backup Bookmarks if (Test-Path "$($env:LOCALAPPDATA)\Google\Chrome\User Data\Default\Bookmarks") { if (-not (test-path d:\Backup\Chrome)) { New-Item -Path d:\Backup\Chrome -Type Directory -Force:$true } Copy-Item -Path "$($env:LOCALAPPDATA)\Google\Chrome\User Data\Default\Bookmarks" -Destination d:\Backup\Chrome\ -Force:$true -Confirm:$false } #Google Edge Backup Bookmarks if (Test-Path "$($env:LOCALAPPDATA)\Microsoft\Edge\User Data\Default\Bookmarks") { if (-not (test-path d:\Backup\Edge)) { New-Item -Path d:\Backup\Edge -Type Directory -Force:$true } Copy-Item -Path "$($env:LOCALAPPDATA)\Microsoft\Edge\User Data\Default\Bookmarks" -Destination d:\Backup\Edge\Bookmarks -Force:$true -Confirm:$false } #Mozilla Firefox Backup Bookmarks if (Test-Path "$($env:APPDATA)\Mozilla\Firefox\Profiles") { if (-not (test-path d:\Backup\FireFox)) { New-Item -Path d:\Backup\FireFox -Type Directory -Force:$true } $MozillaPlaces = (get-childitem "$($env:APPDATA)\Mozilla\Firefox\Profiles" -force -recurse -ErrorAction SilentlyContinue | where-object { $_.Name -eq 'places.sqlite' }).DirectoryName copy-item -path "$MozillaPlaces" -Destination d:\Backup\Firefox -Force:$true -Confirm:$false }
Restore:
#Google Chrome Restore Bookmarks if (Test-Path "$($env:LOCALAPPDATA)\Google\Chrome\User Data\Default\Bookmarks") { if (test-path d:\Backup\Chrome) { Copy-Item -Path d:\Backup\Chrome\bookmarks -destinatiom "$($env:LOCALAPPDATA)\Google\Chrome\User Data\Default\" -Force:$true -Confirm:$false } } #Google Edge Restore Bookmarks if (Test-Path "$($env:LOCALAPPDATA)\Microsoft\Edge\User Data\Default\Bookmarks") { if (test-path d:\Backup\Edge) { Copy-Item -Path d:\Backup\Edge\bookmarks -destination "$($env:LOCALAPPDATA)\Microsoft\Edge\User Data\Default\" -Force:$true -Confirm:$false } } #Mozilla Firefox Restore Bookmarks # To copy it back... SIDE NOTE*** if mozilla being re-installed or fresah installed, must open mozilla first to recreate a default place.sqlite to replace if (Test-Path "$($env:APPDATA)\Mozilla\Firefox\Profiles") { if (test-path d:\Backup\FireFox) { $MozillaPlaces = (get-childitem "$($env:APPDATA)\Mozilla\Firefox\Profiles" -force -recurse -ErrorAction SilentlyContinue | where-object Name -eq 'places.sqlite').DirectoryName Copy-Item D:\Backup\FireFox\*.* -Recurse -Destination "$($MozillaPlaces)" -Force:$true -Confirm:$false } }
Please test this, I only tested backupping everything, not the restore part 😛
- Did this work for you?