Fetch Web Browsing History

SOTI MobiControl
Windows

Employees may use their company-owned devices for personal browsing, which can sometimes lead to security concerns or inefficiencies. The Retrieve Web Browsing History script allows IT administrators to remotely collect web browsing data from Windows devices, enabling the review of websites visited on corporate devices. This eliminates the need for manual inspection of individual devices, saving time and effort. With browsing history retrieval, administrators can ensure compliance with company policies and address any potential risks associated with non-work-related web usage.

Important:
  • It is recommended to test the script on a local/ test machine for its purpose and effects. 
  • SOTI MobiControl will not be responsible for any damage/loss to the data/setup based on the behavior of the script.

Fetch the browsing history of Google Chrome

1 $UserName = "YourActualUsername" # Replace with your Windows username
2 $HistoryPath = "$Env:SystemDrive\Users\$UserName\AppData\Local\Google\Chrome\User Data\Default\History"
3 # Check if file exists
4 if (-not (Test-Path -Path $HistoryPath)) {
5 Write-Error "Could not find Chrome History for username: $UserName"
6 exit
7 }
8 # Read binary file as string
9 $Content = [System.Text.Encoding]::ASCII.GetString([IO.File]::ReadAllBytes($HistoryPath))
10 # Extract URLs using regex
11 $Regex = 'https?://[^\s"]+'
12 $Matches = [regex]::Matches($Content, $Regex) | ForEach-Object { $_.Value } | Sort-Object -Unique
13 # Display result
14 $Matches | ForEach-Object {
15 [PSCustomObject]@{
16 User = $UserName
17 Browser = 'Chrome'
18 DataType = 'History'
19 Data = $_
20 }
21 }
22 Write-Host "`nScript completed. Press Enter to exit..." -ForegroundColor Green
23 [void][System.Console]::ReadLine()

Fetch the browsing history of Microsoft Edge

1 $UserName = "USERNAME"
2 $OriginalPath = "$Env:SystemDrive\Users\$UserName\AppData\Local\Microsoft\Edge\User Data\Default\History"
3 $TempCopy = "$env:TEMP\EdgeHistoryCopy"
4 # Check if file exists
5 if (-not (Test-Path -Path $OriginalPath)) {
6 Write-Error "Could not find Edge History for username: $UserName"
7 exit
8 }
9 # Make a temporary copy (because the original is locked while Edge is running)
10 Copy-Item -Path $OriginalPath -Destination $TempCopy -Force
11 # Read binary file as string from temp copy
12 $Content = [System.Text.Encoding]::ASCII.GetString([IO.File]::ReadAllBytes($TempCopy))
13 # Extract URLs using regex
14 $Regex = 'https?://[^\s"]+'
15 $Matches = [regex]::Matches($Content, $Regex) | ForEach-Object { $_.Value } | Sort-Object -Unique
16 # Display results
17 $Matches | ForEach-Object {
18 [PSCustomObject]@{
19 User = $UserName
20 Browser = 'Edge'
21 DataType = 'History'
22 Data = $_
23 }
24 }
25 # Cleanup (optional)
26 Remove-Item $TempCopy -Force
27 # Prevent window from closing immediately
28 Write-Host "`nScript completed. Press Enter to exit..." -ForegroundColor Green
29 [void][System.Console]::ReadLine()

Fetch the browsing history of Mozilla Firefox

1 # Manually set the full profile path (you found it)
2 $ProfileFolder = "C:\Users\<username>\AppData\Roaming\Mozilla\Firefox\Profiles\71xtzklr.default-release"
3 $HistoryFile = Join-Path $ProfileFolder "places.sqlite"
4 $TempCopy = "$env:TEMP\FirefoxHistoryCopy.sqlite"
5 # Check if the file exists
6 if (-not (Test-Path -Path $HistoryFile)) {
7 Write-Error "places.sqlite file not found in: $ProfileFolder"
8 exit
9 }
10 # Copy the file to avoid lock issues
11 Copy-Item -Path $HistoryFile -Destination $TempCopy -Force
12 # Read binary content as ASCII (for regex extraction)
13 $Content = [System.Text.Encoding]::ASCII.GetString([IO.File]::ReadAllBytes($TempCopy))
14 # Extract URLs using regex
15 $Regex = 'https?://[^\s"]+'
16 $Matches = [regex]::Matches($Content, $Regex) | ForEach-Object { $_.Value } | Sort-Object -Unique
17 # Output results
18 $UserName = $env:USERNAME
19 $Matches | ForEach-Object {
20 [PSCustomObject]@{
21 User = $UserName
22 Browser = 'Firefox'
23 DataType = 'History'
24 Data = $_
25 }
26 }
27 # Cleanup
28 Remove-Item $TempCopy -Force
29 # Pause before exiting
30 Write-Host "`nScript completed. Press Enter to exit..." -ForegroundColor Green
31 [void][System.Console]::ReadLine()

Was this helpful?

Need more help?
Ask Community