RoamingProfile

Author: Scott Downie

description

User Related Registry Hives, LNK files, etc

paths

73 paths
paths use Windows environment syntax

collection commands

# PowerShell Artifact Collection Script
# Target: RoamingProfile
# Run as Administrator

#Requires -RunAsAdministrator

$ErrorActionPreference = "Continue"
$SourceRoot = "C:"
$DestBase   = "D:\Evidence"
$Summary = @{ Copied = 0; Missed = 0; Errors = 0 }

function Collect-Artifact {
    param(
        [Parameter(Mandatory)][string]$SourceDir,
        [Parameter(Mandatory)][string]$FolderName,
        [string]$FileMask = "*"
    )
    # Expand wildcards in any path segment (e.g. 'Program Files*',
    # 'ScreenConnect Client*'). robocopy itself does not glob the source.
    $sources = @(Get-Item -Path $SourceDir -ErrorAction SilentlyContinue |
        Where-Object { $_.PSIsContainer })
    if ($sources.Count -eq 0) {
        $Summary.Missed++
        return
    }
    $FullDest = Join-Path -Path $DestBase -ChildPath $FolderName
    $null = New-Item -ItemType Directory -Force -Path $FullDest -ErrorAction SilentlyContinue
    foreach ($src in $sources) {
        robocopy $src.FullName "$FullDest" "$FileMask" /E /COPY:DAT /R:0 /W:0 /NP /NFL /NDL /NJH /NJS 2>$null | Out-Null
        if ($LASTEXITCODE -le 7) { $Summary.Copied++ } else { $Summary.Errors++ }
    }
}

# 1. NTUSER.DAT registry hive
Collect-Artifact -SourceDir "C:" -FileMask "NTUSER.DAT" -FolderName "NTUSER_DAT_registry_hive"

# 2. NTUSER.DAT registry transaction files
Collect-Artifact -SourceDir "C:" -FileMask "NTUSER.DAT.LOG*" -FolderName "NTUSER_DAT_registry_transaction_files"

# 3. NTUSER.DAT DEFAULT registry hive
Collect-Artifact -SourceDir "C:" -FileMask "DEFAULT" -FolderName "NTUSER_DAT_DEFAULT_registry_hive"

# 4. NTUSER.DAT DEFAULT transaction files
Collect-Artifact -SourceDir "C:" -FileMask "DEFAULT.LOG*" -FolderName "NTUSER_DAT_DEFAULT_transaction_files"

# 5. UsrClass.dat registry hive
Collect-Artifact -SourceDir "C:" -FileMask "UsrClass.dat" -FolderName "UsrClass_dat_registry_hive"

# 6. UsrClass.dat registry transaction files
Collect-Artifact -SourceDir "C:" -FileMask "UsrClass.dat.LOG*" -FolderName "UsrClass_dat_registry_transaction_files"

# 7. LNK Files
Collect-Artifact -SourceDir "C:" -FileMask "*.LNK" -FolderName "LNK_Files"

# 8. Amcache
Collect-Artifact -SourceDir "C:" -FileMask "Amcache.hve" -FolderName "Amcache"

# 9. Amcache transaction files
Collect-Artifact -SourceDir "C:" -FileMask "Amcache.hve.LOG*" -FolderName "Amcache_transaction_files"

# 10. Desktop LNK Files
Collect-Artifact -SourceDir "C:" -FileMask "*.LNK" -FolderName "Desktop_LNK_Files"

# Iterate every user profile under the source drive
Get-ChildItem "$SourceRoot\Users" -Directory -ErrorAction SilentlyContinue |
    Where-Object { $_.Name -notin @('All Users', 'Default', 'Default User', 'Public') } |
    ForEach-Object {
        $UserName = $_.Name
        # Word Autosave Location
        $UserPath = "$($_.FullName)\AppData\Roaming\Microsoft\Word"
        Collect-Artifact -SourceDir $UserPath -FolderName "Word_Autosave_Location_$UserName"
        # Excel Autosave Location
        $UserPath = "$($_.FullName)\AppData\Roaming\Microsoft\Excel"
        Collect-Artifact -SourceDir $UserPath -FolderName "Excel_Autosave_Location_$UserName"
        # PowerPoint Autosave Location
        $UserPath = "$($_.FullName)\AppData\Roaming\Microsoft\PowerPoint"
        Collect-Artifact -SourceDir $UserPath -FolderName "PowerPoint_Autosave_Location_$UserName"
        # Publisher Autosave Location
        $UserPath = "$($_.FullName)\AppData\Roaming\Microsoft\Publisher"
        Collect-Artifact -SourceDir $UserPath -FolderName "Publisher_Autosave_Location_$UserName"
        # Publisher Autosave Location
        $UserPath = "$($_.FullName)\AppData\Roaming\Microsoft\Word"
        Collect-Artifact -SourceDir $UserPath -FolderName "Publisher_Autosave_Location_$UserName"
        # Office Document Cache
        $UserPath = "$($_.FullName)\AppData\Local\Microsoft\Office\*\OfficeFileCache"
        Collect-Artifact -SourceDir $UserPath -FolderName "Office_Document_Cache_$UserName"
        # Office Document Cache
        $UserPath = "$($_.FullName)\AppData\Local\Microsoft\Office\*\OfficeFileCache"
        Collect-Artifact -SourceDir $UserPath -FolderName "Office_Document_Cache_$UserName"
        # Chrome bookmarks
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Bookmarks*" -FolderName "Chrome_bookmarks_$UserName"
        # Chrome bookmarks
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Bookmarks*" -FolderName "Chrome_bookmarks_$UserName"
        # Chrome Cookies
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Cookies*" -FolderName "Chrome_Cookies_$UserName"
        # Chrome Cookies
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Cookies*" -FolderName "Chrome_Cookies_$UserName"
        # Chrome Current Session
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Current Session" -FolderName "Chrome_Current_Session_$UserName"
        # Chrome Current Session
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Current Session" -FolderName "Chrome_Current_Session_$UserName"
        # Chrome Current Tabs
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Current Tabs" -FolderName "Chrome_Current_Tabs_$UserName"
        # Chrome Current Tabs
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Current Tabs" -FolderName "Chrome_Current_Tabs_$UserName"
        # Chrome Download Metadata
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Download Metadata" -FolderName "Chrome_Download_Metadata_$UserName"
        # Chrome Download Metadata
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Download Metadata" -FolderName "Chrome_Download_Metadata_$UserName"
        # Chrome Extension Cookies
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Extension Cookies" -FolderName "Chrome_Extension_Cookies_$UserName"
        # Chrome Extension Cookies
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Extension Cookies" -FolderName "Chrome_Extension_Cookies_$UserName"
        # Chrome Favicons
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Favicons*" -FolderName "Chrome_Favicons_$UserName"
        # Chrome Favicons
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Favicons*" -FolderName "Chrome_Favicons_$UserName"
        # Chrome History
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "History*" -FolderName "Chrome_History_$UserName"
        # Chrome History
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "History*" -FolderName "Chrome_History_$UserName"
        # Chrome Last Session
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Last Session" -FolderName "Chrome_Last_Session_$UserName"
        # Chrome Last Session
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Last Session" -FolderName "Chrome_Last_Session_$UserName"
        # Chrome Last Tabs
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Last Tabs" -FolderName "Chrome_Last_Tabs_$UserName"
        # Chrome Last Tabs
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Last Tabs" -FolderName "Chrome_Last_Tabs_$UserName"
        # Chrome Sessions Folder
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*\Sessions"
        Collect-Artifact -SourceDir $UserPath -FolderName "Chrome_Sessions_Folder_$UserName"
        # Chrome Sessions Folder
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*\Sessions"
        Collect-Artifact -SourceDir $UserPath -FolderName "Chrome_Sessions_Folder_$UserName"
        # Chrome Login Data
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Login Data" -FolderName "Chrome_Login_Data_$UserName"
        # Chrome Login Data
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Login Data" -FolderName "Chrome_Login_Data_$UserName"
        # Chrome Media History
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Media History*" -FolderName "Chrome_Media_History_$UserName"
        # Chrome Media History
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Media History*" -FolderName "Chrome_Media_History_$UserName"
        # Chrome Network Action Predictor
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Network Action Predictor" -FolderName "Chrome_Network_Action_Predictor_$UserName"
        # Chrome Network Action Predictor
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Network Action Predictor" -FolderName "Chrome_Network_Action_Predictor_$UserName"
        # Chrome Network Persistent State
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Network Persistent State" -FolderName "Chrome_Network_Persistent_State_$UserName"
        # Chrome Network Persistent State
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Network Persistent State" -FolderName "Chrome_Network_Persistent_State_$UserName"
        # Chrome Preferences
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Preferences" -FolderName "Chrome_Preferences_$UserName"
        # Chrome Preferences
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Preferences" -FolderName "Chrome_Preferences_$UserName"
        # Chrome Quota Manager
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "QuotaManager" -FolderName "Chrome_Quota_Manager_$UserName"
        # Chrome Quota Manager
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "QuotaManager" -FolderName "Chrome_Quota_Manager_$UserName"
        # Chrome Reporting and NEL
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Reporting and NEL" -FolderName "Chrome_Reporting_and_NEL_$UserName"
        # Chrome Reporting and NEL
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Reporting and NEL" -FolderName "Chrome_Reporting_and_NEL_$UserName"
        # Chrome Shortcuts
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Shortcuts*" -FolderName "Chrome_Shortcuts_$UserName"
        # Chrome Shortcuts
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Shortcuts*" -FolderName "Chrome_Shortcuts_$UserName"
        # Chrome Top Sites
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Top Sites*" -FolderName "Chrome_Top_Sites_$UserName"
        # Chrome Top Sites
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Top Sites*" -FolderName "Chrome_Top_Sites_$UserName"
        # Chrome Trust Tokens
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Trust Tokens*" -FolderName "Chrome_Trust_Tokens_$UserName"
        # Chrome Trust Tokens
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Trust Tokens*" -FolderName "Chrome_Trust_Tokens_$UserName"
        # Chrome SyncData Database
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*\Sync Data"
        Collect-Artifact -SourceDir $UserPath -FileMask "SyncData.sqlite3" -FolderName "Chrome_SyncData_Database_$UserName"
        # Chrome SyncData Database
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*\Sync Data"
        Collect-Artifact -SourceDir $UserPath -FileMask "SyncData.sqlite3" -FolderName "Chrome_SyncData_Database_$UserName"
        # Chrome Visited Links
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Visited Links" -FolderName "Chrome_Visited_Links_$UserName"
        # Chrome Visited Links
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Visited Links" -FolderName "Chrome_Visited_Links_$UserName"
        # Chrome Web Data
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Web Data*" -FolderName "Chrome_Web_Data_$UserName"
        # Chrome Web Data
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*"
        Collect-Artifact -SourceDir $UserPath -FileMask "Web Data*" -FolderName "Chrome_Web_Data_$UserName"
        # Windows Protect Folder
        $UserPath = "$($_.FullName)\AppData\Roaming\Microsoft\Protect\*"
        Collect-Artifact -SourceDir $UserPath -FolderName "Windows_Protect_Folder_$UserName"
        # Windows Protect Folder
        $UserPath = "$($_.FullName)\AppData\Roaming\Microsoft\Protect\*"
        Collect-Artifact -SourceDir $UserPath -FolderName "Windows_Protect_Folder_$UserName"
        # Edge folder
        $UserPath = "$($_.FullName)\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe"
        Collect-Artifact -SourceDir $UserPath -FolderName "Edge_folder_$UserName"
        # Edge folder
        $UserPath = "$($_.FullName)\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe"
        Collect-Artifact -SourceDir $UserPath -FolderName "Edge_folder_$UserName"
        # LNK Files from Recent
        $UserPath = "$($_.FullName)\AppData\Roaming\Microsoft\Windows\Recent"
        Collect-Artifact -SourceDir $UserPath -FolderName "LNK_Files_from_Recent_$UserName"
        # LNK Files from Recent
        $UserPath = "$($_.FullName)\AppData\Roaming\Microsoft\Windows\Recent"
        Collect-Artifact -SourceDir $UserPath -FolderName "LNK_Files_from_Recent_$UserName"
        # LNK Files from Microsoft Office Recent
        $UserPath = "$($_.FullName)\AppData\Roaming\Microsoft\Office\Recent"
        Collect-Artifact -SourceDir $UserPath -FolderName "LNK_Files_from_Microsoft_Office_Recent_$UserName"
        # LNK Files from Microsoft Office Recent
        $UserPath = "$($_.FullName)\AppData\Roaming\Microsoft\Office\Recent"
        Collect-Artifact -SourceDir $UserPath -FolderName "LNK_Files_from_Microsoft_Office_Recent_$UserName"
    }

Write-Host ("Collection complete. Copied: {0}  Missed: {1}  Errors: {2}" -f $Summary.Copied, $Summary.Missed, $Summary.Errors) -ForegroundColor Green

Save as .ps1 and run as Administrator. Use: powershell -ExecutionPolicy Bypass -File script.ps1