IE, Edge 및 Chrome용 북마크/즐겨찾기를 다른 드라이브에 백업하는 Powershell 스크립트

IE, Edge 및 Chrome용 북마크/즐겨찾기를 다른 드라이브에 백업하는 Powershell 스크립트

노트북이 손상될 경우 IE, Edge 및 Chrome의 모든 즐겨찾기/북마크를 별도의 드라이브에 자동으로 백업하도록 예약할 수 있는 PowerShell 스크립트를 찾고 있습니다.

누구든지 도와줄 수 있나요? 정말 감사하겠습니다.

감사합니다!

답변1

스크립트EdgeChromium-책갈피-백업-JSON-to-HTML.ps1Edge에 대해 요청한 작업을 수행합니다(Chrome을 사용해 본 적은 없지만 작동할 수도 있다고 가정합니다).

EdgeChromium Beta 78용으로 작성되었지만 이 글을 쓰는 시점에는 여전히 Edge 버전 91까지 작동합니다.

다음 줄을 수정해야 합니다.

$JSON_File_Path = "$env:localappdata\Microsoft\Edge Beta\User Data\Default\Bookmarks"

에게

$JSON_File_Path = "$env:localappdata\Microsoft\Edge\User Data\Default\Bookmarks"

backup다음 경로에 이름이 지정된 폴더를 만듭니다 $env:userprofile\backup( C:\Users\Username\backup사용자 이름을 사용자 이름으로 변경).

답변2

Edge v98과 함께 작동하도록 업데이트되었으며 즐겨찾기 표시줄 문제가 정렬되었습니다. GitHub 풀 요청

# Read EdgeChromium Bookmarks (JSON File) and Export/Backup to HTML File
# Gunnar Haslinger, 30.10.2019 - tested width EdgeChromium Beta 78
# SCCMOG - Richie Schuster, 2022.02.08 - Tested with Edge Chromium 98.0.1108.43 - https://github.com/SCCMOG - SCCMOG.com

# Path to EdgeChromium Bookmarks File and HTML Export
$JSON_File_Path = "$($env:localappdata)\Microsoft\Edge\User Data\Default\Bookmarks"
$ExportedTime = Get-Date -Format 'yyyy-MM-dd_HH.mm'
$HTML_File_Root = "c:\admin"
$HTML_File_Path = "$($HTML_File_Root)\EdgeChromium-Bookmarks.backup_$($ExportedTime).html"
# Reference-Timestamp needed to convert Timestamps of JSON (Milliseconds / Ticks since LDAP / NT epoch 01.01.1601 00:00:00 UTC) to Unix-Timestamp (Epoch)
$Date_LDAP_NT_EPOCH = Get-Date -Year 1601 -Month 1 -Day 1 -Hour 0 -Minute 0 -Second 0

if (!(Test-Path -Path $JSON_File_Path -PathType Leaf)) {
    throw "Source-File Path $JSON_File_Path does not exist!" 
}
if (!(Test-Path -Path $HTML_File_Root -PathType Container)) { 
    throw "Destination-Root Path $HTML_File_Root does not exist!" 
}

# ---- HTML Header ----
$BookmarksHTML_Header = @'
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
     It will be read and overwritten.
     DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
'@

$BookmarksHTML_Header | Out-File -FilePath $HTML_File_Path -Force -Encoding utf8

# ---- Enumerate Bookmarks Folders ----
Function Get-BookmarkFolder {
    [cmdletbinding()] 
    Param( 
        [Parameter(Position = 0, ValueFromPipeline = $True)]
        $Node 
    )
    function ConvertTo-UnixTimeStamp {
        param(
            [Parameter(Position = 0, ValueFromPipeline = $True)]
            $TimeStamp 
        )
        $date = [Decimal] $TimeStamp
        if ($date -gt 0) { 
            $date = $Date_LDAP_NT_EPOCH.AddTicks($date * 10)
            $date = $date | Get-Date -UFormat %s 
            $unixTimeStamp = [int][double]::Parse($date) - 1
            return $unixTimeStamp
        }
    }   
    if ($node.name -like "Favorites Bar") {
        $DateAdded = [Decimal] $node.date_added | ConvertTo-UnixTimeStamp
        $DateModified = [Decimal] $node.date_modified | ConvertTo-UnixTimeStamp
        "        <DT><H3 FOLDED ADD_DATE=`"$($DateAdded)`" LAST_MODIFIED=`"$($DateModified)`" PERSONAL_TOOLBAR_FOLDER=`"true`">$($node.name )</H3>" | Out-File -FilePath $HTML_File_Path -Append -Force -Encoding utf8
        "        <DL><p>" | Out-File -FilePath $HTML_File_Path -Append -Force -Encoding utf8
    }
    foreach ($child in $node.children) {
        $DateAdded = [Decimal] $child.date_added | ConvertTo-UnixTimeStamp    
        $DateModified = [Decimal] $child.date_modified | ConvertTo-UnixTimeStamp
        if ($child.type -eq 'folder') {
            "        <DT><H3 ADD_DATE=`"$($DateAdded)`" LAST_MODIFIED=`"$($DateModified)`">$($child.name)</H3>" | Out-File -FilePath $HTML_File_Path -Append -Force -Encoding utf8
            "        <DL><p>" | Out-File -FilePath $HTML_File_Path -Append -Force -Encoding utf8
            Get-BookmarkFolder $child # Recursive call in case of Folders / SubFolders
            "        </DL><p>" | Out-File -FilePath $HTML_File_Path -Append -Force -Encoding utf8
        }
        else {
            # Type not Folder => URL
            "        <DT><A HREF=`"$($child.url)`" ADD_DATE=`"$($DateAdded)`">$($child.name)</A>" | Out-File -FilePath $HTML_File_Path -Append -Encoding utf8
        }
    }
    if ($node.name -like "Favorites Bar") {
        "        </DL><p>" | Out-File -FilePath $HTML_File_Path -Append -Force -Encoding utf8
    }
}

# ---- Convert the JSON Contens (recursive) ----
$data = Get-content $JSON_File_Path -Encoding UTF8 | out-string | ConvertFrom-Json
$sections = $data.roots.PSObject.Properties | Select-Object -ExpandProperty name
ForEach ($entry in $sections) { 
    $data.roots.$entry | Get-BookmarkFolder
}

# ---- HTML Footer ----
'</DL>' | Out-File -FilePath $HTML_File_Path -Append -Force -Encoding utf8

관련 정보