Category filter
Script to configure Chrome managed bookmarks for Windows
A bookmark allows users to gather their important or frequently visited web pages under a single location within a web browser. This enables users to access these specific web pages with a simple click directly from their browser’s homepage. As an IT administrator, you can create and organize managed bookmarks, giving users quick access to relevant web resources when they’re signed in. Users cannot remove them from the browser. To configure Chrome managed bookmarks for Windows, you can use the script provided in this document. IT administrators can use Hexnode’s Execute Custom Script remote action to deploy the following PowerShell scripts to a group of Windows devices remotely.
PowerShell
Adding bookmarks to the Google Chrome browser
The following script modifies the Windows registry to enable bookmark bar in the Google Chrome browser by setting the value of the key “BookmarkBarEnabled” to ‘1’. A series of bookmarks can be listed under this registry with a name and a designated URL. A bookmark folder can also be created using the ‘children’ key in the script to group similar types of bookmarks together.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
#Enable bookmark bar and add bookmarks in chrome $registryPath = 'HKLM:\Software\Policies\Google\Chrome' $enableBookmarkBar = 1 #set as 0 to disable it. if(-not(Test-Path $registryPath)) { New-Item -Path $registryPath -Force | Out-Null } #setting BookmarkBarEnabled registry name Set-ItemProperty -Path $registryPath -Name BookmarkBarEnabled -Value $enableBookmarkBar -Force | Out-Null Write-Host "Chrome policy key created and bookmark bar enabled." #add required bookmarks $bookmarkJson = '[ { "toplevel_name": "My managed bookmarks folder" }, { "name": "Google", "url": "google.com" }, { "name": "Youtube", "url": "youtube.com" }, { "children": [ { "name": "Chromium", "url": "chromium.org" }, { "name": "Chromium Developers", "url": "dev.chromium.org" } ], "name": "Chrome links" } ]' Set-ItemProperty -Path $registryPath -Name ManagedBookmarks -Value $bookmarkJson -Force | Out-Null Write-Host "ManagedBookmarks registry key created and bookmarks added." |
The above script creates a bookmark bar named “My managed bookmarks folder” and adds two bookmarks named Google and YouTube with their designated URLs. It also creates a bookmark folder in the list named ‘Chrome links’ to contain two bookmarks related to Chrome. The script adds the list of bookmarks to the registry using a JSON key $bookmarkJson. The bookmark bar can be disabled by setting the value of the variable $enableBookmarkBar to 0. The enabled bookmarks bar and any added bookmarks can be viewed in the top-left corner of the Google Chrome browser on Windows devices.
Remove bookmarks from Google Chrome browser
The following script can be used to clear the registry values set by the previous script, thereby removing all the added bookmarks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$registryPath = 'HKLM:\Software\Policies\Google\Chrome' # Check if ManagedBookmarks key exists and has data $managedBookmarksKey = Get-ItemProperty -Path $registryPath -Name ManagedBookmarks -ErrorAction SilentlyContinue if ($managedBookmarksKey -ne $null -and $managedBookmarksKey.ManagedBookmarks -ne $null) { # Delete ManagedBookmarks key Remove-ItemProperty -Path $registryPath -Name ManagedBookmarks -Force | Out-Null # Display success message Write-Host "ManagedBookmarks registry key deleted and bookmarks restored to default." } else { # Display nothing to delete message Write-Host " There are currently no bookmarks present that can be deleted." } |
The script first checks if any bookmarks are present in the registry. If bookmarks exist, the script deletes the registry entries and displays the message “ManagedBookmarks registry key deleted and bookmarks restored to default.” If no bookmarks are found, the script displays the message “There are currently no bookmarks present that can be deleted.”