Securing user data when reinstalling or replacing PCs

Sune Jensen 0 Reputation points
2025-10-09T09:20:29.7333333+00:00

I'm primary responsible in my new job for Setting up PCs for our users, it be reinstalls or replacements.

In that process I spend a lot of time

#1 securing that there no stray documents and user data on the local drive,

#2 noting what extra software is installed

#3 and noting what printers are used.

I'm wondering if there is some scripts or tools capable of helping with this and perhaps also collecting other user settings?

Windows for business | Windows Client for IT Pros | Devices and deployment | Set up, install, or upgrade

Locked Question. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Marcin Policht 101K Reputation points MVP Volunteer Moderator
    2025-10-09T12:19:20.52+00:00

    There are some ways to automate the collection of user data, installed software, printers, and even settings before a rebuild or replacement. You can approach this in two levels:

    Task What to Collect Possible Automation Approach
    #1 Stray documents / user data Files on Desktop, Documents, Downloads, etc. PowerShell scripts or USMT scanstate
    #2 Installed software Installed programs and version numbers PowerShell (Get-ItemProperty, WMI, or Win32_Product)
    #3 Printers Installed printers + drivers + default printer PowerShell (Get-Printer, Get-PrintConfiguration)
    Extra Browser favorites, Outlook signatures, network shares, etc. User State Migration Tool (USMT) or custom scripts

    Option 1 — Quick PowerShell-based Inventory (Fast to Deploy)

    You can run this manually or remotely (e.g. via PSRemoting):

    # Collect user data info, installed software, and printers
    $UserProfile = [Environment]::GetFolderPath('UserProfile')
    $OutputPath = "C:\Temp\UserInventory_$(hostname).txt"
    
    # 1. Check for stray documents
    "=== User Files Summary ===" | Out-File $OutputPath
    Get-ChildItem -Path "$UserProfile\Desktop","$UserProfile\Documents","$UserProfile\Downloads" -Recurse -ErrorAction SilentlyContinue |
        Where-Object { -not $_.PSIsContainer } |
        Select-Object FullName, Length, LastWriteTime |
        Out-File -Append $OutputPath
    
    # 2. List installed software
    "`n=== Installed Software ===" | Out-File -Append $OutputPath
    Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*, 
                     HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
        Where-Object { $_.DisplayName } |
        Select-Object DisplayName, DisplayVersion, Publisher |
        Sort-Object DisplayName |
        Out-File -Append $OutputPath
    
    # 3. List printers
    "`n=== Installed Printers ===" | Out-File -Append $OutputPath
    Get-Printer | Select-Object Name, DriverName, PortName, Shared | Out-File -Append $OutputPath
    
    # 4. Optional: capture some user settings
    "`n=== User Settings (Registry) ===" | Out-File -Append $OutputPath
    Get-ItemProperty HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders |
        Out-File -Append $OutputPath
    
    Write-Host "Inventory written to $OutputPath"
    

    This gives you a one-file report per computer that summarizes local files, software, and printers.

    Option 2 — Use Microsoft's User State Migration Tool (USMT)

    USMT is part of the Windows ADK, designed specifically for migrations like yours. It can:

    • Collect user data (Desktop, Documents, AppData)
    • Capture many app & system settings (Outlook profiles, IE favorites, etc.)
    • Restore to a new machine

    Example flow:

    scanstate \\server\backup\$env:COMPUTERNAME /i:miguser.xml /i:migapp.xml /o /v:13 /c /l:scan.log
    

    Then on the new machine:

    loadstate \\server\backup\$env:COMPUTERNAME /i:miguser.xml /i:migapp.xml /v:13 /c /l:load.log
    

    You can customize what gets included/excluded (printers, network drives, PST files, etc.) in the XML config.

    Option 3 — Combine with inventory tools

    If you're managing more machines at scale by using Intune or Endpoint Manager, these collect installed apps, hardware info, and can deploy scripts remotely.

    Option 4 — Hybrid approach

    1. Run the PowerShell script above to capture a quick inventory.
    2. Run USMT (or a smaller robocopy-based script) to collect user data to a network share.
    3. After reinstall/replacement, restore the user profile and settings.

    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    Was this answer helpful?