Hi everyone thanks in advance for your responses. I’m a new bee to powershell and some of my questions might sound silly.
I’m taking a Chrome bookmark file as a sample Json file example.
$chromebookmarkfile = “$env:localappdata\Google\Chrome\User Data\Default\Bookmarks”
$jsonfile = Get-Content $chromebookmarkfile -Raw | ConvertFrom-Json
$jsonfile.Roots.Bookmark_bar.children = @($jsonfile.Roots.Bookmark_bar.children | where { $_.name -notmatch “^.search.$” })
$jsonfile | ConvertTo-Json -Depth 5 | Out-File “C:\Users\Name\Desktop\bookmarkupdated.js” -Encoding UTF8
After some googling, i’m able to filter the results that does not matches the word “search”, but when I try to replace instead of filtering, I’m facing hard time
$jsonfile.Roots.Bookmark_bar.children = @($jsonfile.Roots.Bookmark_bar.children | if( $.name -match “^.search.$”){$.name = “Success”})
Please correct me where i’m doing wrong. Thank you again for your time.