#requires -version 3.0 <# .Synopsis Get Google Chrome Bookmarks .Description This script will enumerate all Google Chrome bookmarks. If you use -validate it will use Invoke-Webrequest to test if the link is still valid. This script requires PowerShell v3. DO NOT RUN THIS IN THE POWERSHELL ISE USING -VALIDATE INVOKE-WEBREQUEST COULD RUN AWAY WITH MEMORY .Parameter File The path to the Google Chrome bookmarks file. .Parameter Validate Use Invoke-Webrequest to validate the url. DO NOT USE THIS IF RUNNING THE SCRIPT IN THE POWERSHELL ISE. .Example PS S:\> .\Get-Chromebookmark.ps1 .Example PS S:\> .\Get-Chromebookmark.ps1 -validate | Where {-Not ($_.valid)} Find all invalid or untested bookmarks .Example PS S:\> .\Get-ChromeBookmark.ps1 | format-table -group folder Name,URL,Added Create a formatted table report of bookmarks grouped by folder. .Notes Last Updated: November 23, 2012 Version : 0.9 .Link ConvertFrom-JSON Invoke-Webrequest .Inputs None .Outputs Custom object #> [cmdletbinding()] Param ( [Parameter(Position=0)] [ValidateScript({Test-Path $_})] [string]$File = "$env:localappdata\Google\Chrome\User Data\Default\Bookmarks", [switch]$Validate ) Write-Verbose -Message "Starting $($MyInvocation.Mycommand)" #A nested function to enumerate bookmark folders Function Get-BookmarkFolder { [cmdletbinding()] Param( [Parameter(Position=0,ValueFromPipeline=$True)] $Node ) Process { foreach ($child in $node.children) { #get parent folder name $parent = $node.Name if ($child.type -eq 'Folder') { Write-Verbose "Processing $($child.Name)" Get-BookmarkFolder $child } else { $hash= [ordered]@{ Folder = $parent Name = $child.name URL = $child.url Added = [datetime]::FromFileTime(([double]$child.Date_Added)*10) Valid = $Null Status = $Null } If ($Validate) { Write-Verbose "Validating $($child.url)" if ($child.url -match "^http") { #only test if url starts with http or https Try { $r = Invoke-WebRequest -Uri $child.url -DisableKeepAlive -UseBasicParsing if ($r.statuscode -eq 200) { $hash.Valid = $True } #if statuscode else { $hash.valid = $False } $hash.status = $r.statuscode Remove-Variable -Name r -Force } Catch { Write-Warning "Could not validate $($child.url)" $hash.valid = $False $hash.status = $Null } } #if url } #if validate #write custom object New-Object -TypeName PSobject -Property $hash } #else url } #foreach } #process } #end function #convert Google Chrome Bookmark filefrom JSON $data = Get-Content $file | Out-String | ConvertFrom-Json #these should be the top level "folders" $data.roots.bookmark_bar | Get-BookmarkFolder $data.roots.other | Get-BookmarkFolder $data.roots.synced | Get-BookmarkFolder Write-Verbose -Message "Ending $($MyInvocation.Mycommand)"