Remove Chrome Bookmarks with Powershell
I am looking for a way in powershell to remove and add bookmarks to chrome. Chrome Bookmarks are stored in a JSON file formatted like below, with the actual bookmarks being stored in the $data.roots.bookmark_bar.children object. I have tried something like this:
$data = Get-content $chromebookmarkfile | out-string | ConvertFrom-Json
$data | Where-Object {$data.Roots.Bookmark_bar.children.Name -Notmatch "^NA"} | Convertto-JSON | Out-File "C:UsersNameDesktopbookmarkupdated.js"
and it seems to remove all the bookmarks.
> { "checksum": "f8d56bf82388c64d566247e1f510d0c8", "roots": {
> "bookmark_bar": {
> "children": [ {
> "date_added": "13186673111751399",
> "id": "5",
> "meta_info": {
> "last_visited_desktop": "13189831127309905"
> },
> "name": "Facebook",
> "type": "url",
> "url": "https://www.facebook.com/"
> }],
> "date_added": "13186673028532299",
> "date_modified": "13189832329106862",
> "id": "1",
> "name": "Bookmarks bar",
> "type": "folder"
> },
> "other": {
> "children": [ ],
> "date_added": "13186673028532314",
> "date_modified": "0",
> "id": "2",
> "name": "Other bookmarks",
> "type": "folder"
> },
> "synced": {
> "children": [ ],
> "date_added": "13186673028532317",
> "date_modified": "0",
> "id": "3",
> "name": "Mobile bookmarks",
> "type": "folder"
> } }, "version": 1 }
Any help is appreciated.

migrated from security.stackexchange.com Dec 27 '18 at 7:55
This question came from our site for information security professionals.
add a comment |
I am looking for a way in powershell to remove and add bookmarks to chrome. Chrome Bookmarks are stored in a JSON file formatted like below, with the actual bookmarks being stored in the $data.roots.bookmark_bar.children object. I have tried something like this:
$data = Get-content $chromebookmarkfile | out-string | ConvertFrom-Json
$data | Where-Object {$data.Roots.Bookmark_bar.children.Name -Notmatch "^NA"} | Convertto-JSON | Out-File "C:UsersNameDesktopbookmarkupdated.js"
and it seems to remove all the bookmarks.
> { "checksum": "f8d56bf82388c64d566247e1f510d0c8", "roots": {
> "bookmark_bar": {
> "children": [ {
> "date_added": "13186673111751399",
> "id": "5",
> "meta_info": {
> "last_visited_desktop": "13189831127309905"
> },
> "name": "Facebook",
> "type": "url",
> "url": "https://www.facebook.com/"
> }],
> "date_added": "13186673028532299",
> "date_modified": "13189832329106862",
> "id": "1",
> "name": "Bookmarks bar",
> "type": "folder"
> },
> "other": {
> "children": [ ],
> "date_added": "13186673028532314",
> "date_modified": "0",
> "id": "2",
> "name": "Other bookmarks",
> "type": "folder"
> },
> "synced": {
> "children": [ ],
> "date_added": "13186673028532317",
> "date_modified": "0",
> "id": "3",
> "name": "Mobile bookmarks",
> "type": "folder"
> } }, "version": 1 }
Any help is appreciated.

migrated from security.stackexchange.com Dec 27 '18 at 7:55
This question came from our site for information security professionals.
add a comment |
I am looking for a way in powershell to remove and add bookmarks to chrome. Chrome Bookmarks are stored in a JSON file formatted like below, with the actual bookmarks being stored in the $data.roots.bookmark_bar.children object. I have tried something like this:
$data = Get-content $chromebookmarkfile | out-string | ConvertFrom-Json
$data | Where-Object {$data.Roots.Bookmark_bar.children.Name -Notmatch "^NA"} | Convertto-JSON | Out-File "C:UsersNameDesktopbookmarkupdated.js"
and it seems to remove all the bookmarks.
> { "checksum": "f8d56bf82388c64d566247e1f510d0c8", "roots": {
> "bookmark_bar": {
> "children": [ {
> "date_added": "13186673111751399",
> "id": "5",
> "meta_info": {
> "last_visited_desktop": "13189831127309905"
> },
> "name": "Facebook",
> "type": "url",
> "url": "https://www.facebook.com/"
> }],
> "date_added": "13186673028532299",
> "date_modified": "13189832329106862",
> "id": "1",
> "name": "Bookmarks bar",
> "type": "folder"
> },
> "other": {
> "children": [ ],
> "date_added": "13186673028532314",
> "date_modified": "0",
> "id": "2",
> "name": "Other bookmarks",
> "type": "folder"
> },
> "synced": {
> "children": [ ],
> "date_added": "13186673028532317",
> "date_modified": "0",
> "id": "3",
> "name": "Mobile bookmarks",
> "type": "folder"
> } }, "version": 1 }
Any help is appreciated.

I am looking for a way in powershell to remove and add bookmarks to chrome. Chrome Bookmarks are stored in a JSON file formatted like below, with the actual bookmarks being stored in the $data.roots.bookmark_bar.children object. I have tried something like this:
$data = Get-content $chromebookmarkfile | out-string | ConvertFrom-Json
$data | Where-Object {$data.Roots.Bookmark_bar.children.Name -Notmatch "^NA"} | Convertto-JSON | Out-File "C:UsersNameDesktopbookmarkupdated.js"
and it seems to remove all the bookmarks.
> { "checksum": "f8d56bf82388c64d566247e1f510d0c8", "roots": {
> "bookmark_bar": {
> "children": [ {
> "date_added": "13186673111751399",
> "id": "5",
> "meta_info": {
> "last_visited_desktop": "13189831127309905"
> },
> "name": "Facebook",
> "type": "url",
> "url": "https://www.facebook.com/"
> }],
> "date_added": "13186673028532299",
> "date_modified": "13189832329106862",
> "id": "1",
> "name": "Bookmarks bar",
> "type": "folder"
> },
> "other": {
> "children": [ ],
> "date_added": "13186673028532314",
> "date_modified": "0",
> "id": "2",
> "name": "Other bookmarks",
> "type": "folder"
> },
> "synced": {
> "children": [ ],
> "date_added": "13186673028532317",
> "date_modified": "0",
> "id": "3",
> "name": "Mobile bookmarks",
> "type": "folder"
> } }, "version": 1 }
Any help is appreciated.


asked Dec 21 '18 at 3:47
ThomasThomas
22118
22118
migrated from security.stackexchange.com Dec 27 '18 at 7:55
This question came from our site for information security professionals.
migrated from security.stackexchange.com Dec 27 '18 at 7:55
This question came from our site for information security professionals.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You could do it like this:
$json = Get-Content $chromebookmarkfile -Raw | ConvertFrom-Json
$json.Roots.Bookmark_bar.children = @($json.Roots.Bookmark_bar.children | where { $_.name -notmatch "^NA" })
$json | ConvertTo-Json -Depth 10 | Out-File "C:UsersNameDesktopbookmarkupdated.js" -Encoding UTF8
1
This works like a dream creating the file. However, I run into a similar problem when I brute force creating the text of the file....when I replace the current Bookmarks file with the new one created by the script, Chrome does not load with any bookmarks. However, if I open the original Chrome-created bookmark file and overwrite all the text from the one created by the script it works and removes the correct bookmarks. This one has me scratching my head. Its almost like the Chrome application fingerprints the file somehow.
– Thomas
Dec 28 '18 at 14:06
1
I fixed it. Looks like Chrome encodes the file in UTF-8 and powershell's default is something different. This fixed the issue: $json | ConvertTo-Json -Depth 10 | Out-File "d:tmpbookmarkupdated.js" -Encoding UTF8
– Thomas
Dec 28 '18 at 16:09
@Thomas Great find. I've included that in the answer.
– marsze
Jan 2 at 11:48
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53941613%2fremove-chrome-bookmarks-with-powershell%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could do it like this:
$json = Get-Content $chromebookmarkfile -Raw | ConvertFrom-Json
$json.Roots.Bookmark_bar.children = @($json.Roots.Bookmark_bar.children | where { $_.name -notmatch "^NA" })
$json | ConvertTo-Json -Depth 10 | Out-File "C:UsersNameDesktopbookmarkupdated.js" -Encoding UTF8
1
This works like a dream creating the file. However, I run into a similar problem when I brute force creating the text of the file....when I replace the current Bookmarks file with the new one created by the script, Chrome does not load with any bookmarks. However, if I open the original Chrome-created bookmark file and overwrite all the text from the one created by the script it works and removes the correct bookmarks. This one has me scratching my head. Its almost like the Chrome application fingerprints the file somehow.
– Thomas
Dec 28 '18 at 14:06
1
I fixed it. Looks like Chrome encodes the file in UTF-8 and powershell's default is something different. This fixed the issue: $json | ConvertTo-Json -Depth 10 | Out-File "d:tmpbookmarkupdated.js" -Encoding UTF8
– Thomas
Dec 28 '18 at 16:09
@Thomas Great find. I've included that in the answer.
– marsze
Jan 2 at 11:48
add a comment |
You could do it like this:
$json = Get-Content $chromebookmarkfile -Raw | ConvertFrom-Json
$json.Roots.Bookmark_bar.children = @($json.Roots.Bookmark_bar.children | where { $_.name -notmatch "^NA" })
$json | ConvertTo-Json -Depth 10 | Out-File "C:UsersNameDesktopbookmarkupdated.js" -Encoding UTF8
1
This works like a dream creating the file. However, I run into a similar problem when I brute force creating the text of the file....when I replace the current Bookmarks file with the new one created by the script, Chrome does not load with any bookmarks. However, if I open the original Chrome-created bookmark file and overwrite all the text from the one created by the script it works and removes the correct bookmarks. This one has me scratching my head. Its almost like the Chrome application fingerprints the file somehow.
– Thomas
Dec 28 '18 at 14:06
1
I fixed it. Looks like Chrome encodes the file in UTF-8 and powershell's default is something different. This fixed the issue: $json | ConvertTo-Json -Depth 10 | Out-File "d:tmpbookmarkupdated.js" -Encoding UTF8
– Thomas
Dec 28 '18 at 16:09
@Thomas Great find. I've included that in the answer.
– marsze
Jan 2 at 11:48
add a comment |
You could do it like this:
$json = Get-Content $chromebookmarkfile -Raw | ConvertFrom-Json
$json.Roots.Bookmark_bar.children = @($json.Roots.Bookmark_bar.children | where { $_.name -notmatch "^NA" })
$json | ConvertTo-Json -Depth 10 | Out-File "C:UsersNameDesktopbookmarkupdated.js" -Encoding UTF8
You could do it like this:
$json = Get-Content $chromebookmarkfile -Raw | ConvertFrom-Json
$json.Roots.Bookmark_bar.children = @($json.Roots.Bookmark_bar.children | where { $_.name -notmatch "^NA" })
$json | ConvertTo-Json -Depth 10 | Out-File "C:UsersNameDesktopbookmarkupdated.js" -Encoding UTF8
edited Jan 2 at 11:48
answered Dec 27 '18 at 8:52


marszemarsze
5,87132042
5,87132042
1
This works like a dream creating the file. However, I run into a similar problem when I brute force creating the text of the file....when I replace the current Bookmarks file with the new one created by the script, Chrome does not load with any bookmarks. However, if I open the original Chrome-created bookmark file and overwrite all the text from the one created by the script it works and removes the correct bookmarks. This one has me scratching my head. Its almost like the Chrome application fingerprints the file somehow.
– Thomas
Dec 28 '18 at 14:06
1
I fixed it. Looks like Chrome encodes the file in UTF-8 and powershell's default is something different. This fixed the issue: $json | ConvertTo-Json -Depth 10 | Out-File "d:tmpbookmarkupdated.js" -Encoding UTF8
– Thomas
Dec 28 '18 at 16:09
@Thomas Great find. I've included that in the answer.
– marsze
Jan 2 at 11:48
add a comment |
1
This works like a dream creating the file. However, I run into a similar problem when I brute force creating the text of the file....when I replace the current Bookmarks file with the new one created by the script, Chrome does not load with any bookmarks. However, if I open the original Chrome-created bookmark file and overwrite all the text from the one created by the script it works and removes the correct bookmarks. This one has me scratching my head. Its almost like the Chrome application fingerprints the file somehow.
– Thomas
Dec 28 '18 at 14:06
1
I fixed it. Looks like Chrome encodes the file in UTF-8 and powershell's default is something different. This fixed the issue: $json | ConvertTo-Json -Depth 10 | Out-File "d:tmpbookmarkupdated.js" -Encoding UTF8
– Thomas
Dec 28 '18 at 16:09
@Thomas Great find. I've included that in the answer.
– marsze
Jan 2 at 11:48
1
1
This works like a dream creating the file. However, I run into a similar problem when I brute force creating the text of the file....when I replace the current Bookmarks file with the new one created by the script, Chrome does not load with any bookmarks. However, if I open the original Chrome-created bookmark file and overwrite all the text from the one created by the script it works and removes the correct bookmarks. This one has me scratching my head. Its almost like the Chrome application fingerprints the file somehow.
– Thomas
Dec 28 '18 at 14:06
This works like a dream creating the file. However, I run into a similar problem when I brute force creating the text of the file....when I replace the current Bookmarks file with the new one created by the script, Chrome does not load with any bookmarks. However, if I open the original Chrome-created bookmark file and overwrite all the text from the one created by the script it works and removes the correct bookmarks. This one has me scratching my head. Its almost like the Chrome application fingerprints the file somehow.
– Thomas
Dec 28 '18 at 14:06
1
1
I fixed it. Looks like Chrome encodes the file in UTF-8 and powershell's default is something different. This fixed the issue: $json | ConvertTo-Json -Depth 10 | Out-File "d:tmpbookmarkupdated.js" -Encoding UTF8
– Thomas
Dec 28 '18 at 16:09
I fixed it. Looks like Chrome encodes the file in UTF-8 and powershell's default is something different. This fixed the issue: $json | ConvertTo-Json -Depth 10 | Out-File "d:tmpbookmarkupdated.js" -Encoding UTF8
– Thomas
Dec 28 '18 at 16:09
@Thomas Great find. I've included that in the answer.
– marsze
Jan 2 at 11:48
@Thomas Great find. I've included that in the answer.
– marsze
Jan 2 at 11:48
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53941613%2fremove-chrome-bookmarks-with-powershell%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown