Add Adobe Stamps Backup and Restore scripts (Hermes folder)
This commit is contained in:
parent
768868b955
commit
a117af53de
53
Hermes/Adobe-Stamps-Backup.ps1
Normal file
53
Hermes/Adobe-Stamps-Backup.ps1
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Sichert alle Adobe Acrobat Stempel (Custom Stamps) des aktuellen Benutzers.
|
||||||
|
.DESCRIPTION
|
||||||
|
Kopiert den gesamten Inhalt des Adobe Stamps-Ordners (inkl. Unterordner wie Dynamic)
|
||||||
|
in einen Zielordner. Die Struktur wird als "StampsBackup" abgelegt.
|
||||||
|
.PARAMETER TargetPath
|
||||||
|
Zielordner, in den die Sicherung geschrieben wird. Wird erstellt, falls nicht vorhanden.
|
||||||
|
.EXAMPLE
|
||||||
|
.\Adobe-Stamps-Backup.ps1 -TargetPath "D:\Sicherung\AdobeStamps"
|
||||||
|
#>
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string]$TargetPath
|
||||||
|
)
|
||||||
|
|
||||||
|
# Standardpfad zu den Adobe Acrobat Custom Stamps (Roaming / AppData)
|
||||||
|
# Entspricht %AppData%\Adobe\Acrobat\DC\Stamps
|
||||||
|
$adobeStampsPath = Join-Path $env:APPDATA "Adobe\Acrobat\DC\Stamps"
|
||||||
|
|
||||||
|
# Ziel-Unterordner innerhalb von TargetPath
|
||||||
|
$backupFolder = Join-Path $TargetPath "StampsBackup"
|
||||||
|
|
||||||
|
# 1. Pruefen, ob der Quellordner (Adobe Stamps) existiert
|
||||||
|
if (-not (Test-Path $adobeStampsPath)) {
|
||||||
|
Write-Warning "Der Adobe Stamps-Ordner wurde unter '$adobeStampsPath' nicht gefunden."
|
||||||
|
Write-Warning "Falls noch keine eigenen Stempel erstellt wurden, existiert der Ordner noch nicht."
|
||||||
|
Write-Warning "Erstelle eine Test-Marke in Adobe Acrobat -> Kommentar -> Stempel -> Eigene Stempel,"
|
||||||
|
Write-Warning "damit der Ordner generiert wird, und wiederhole den Vorgang."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# 2. Zielpfad erstellen, falls nicht vorhanden
|
||||||
|
if (-not (Test-Path $backupFolder)) {
|
||||||
|
New-Item -Path $backupFolder -ItemType Directory -Force | Out-Null
|
||||||
|
Write-Host "Der Sicherungsordner '$backupFolder' wurde erstellt."
|
||||||
|
}
|
||||||
|
|
||||||
|
# 3. Alle Stempel (PDF-Dateien und Unterordner) kopieren
|
||||||
|
try {
|
||||||
|
# -Recurse kopiert Unterordner wie Dynamic, Droplist etc. mit
|
||||||
|
Copy-Item -Path $adobeStampsPath\* -Destination $backupFolder -Force -Recurse -ErrorAction Stop
|
||||||
|
|
||||||
|
# Anzahl der kopierten Dateien zaehlen fuer Rueckmeldung
|
||||||
|
$fileCount = (Get-ChildItem -Path $backupFolder -Recurse -File).Count
|
||||||
|
|
||||||
|
Write-Host "Erfolgreich alle Adobe Stempel aus '$adobeStampsPath' nach '$backupFolder' gesichert."
|
||||||
|
Write-Host "Kopierte Dateien: $fileCount"
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error "Fehler bei der Sicherung der Adobe Stempel: $_"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
87
Hermes/Adobe-Stamps-Restore.ps1
Normal file
87
Hermes/Adobe-Stamps-Restore.ps1
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Stellt Adobe Acrobat Custom Stamps aus einer Sicherung wieder her.
|
||||||
|
.DESCRIPTION
|
||||||
|
Lädt alle Stempel aus dem Ordner "StampsBackup" innerhalb des angegebenen
|
||||||
|
Quellpfads zurueck in den lokalen Adobe Stamps-Ordner des Benutzers.
|
||||||
|
Dabei werden alle Dateien ueberschrieben (Merge), Unterordner bleiben erhalten.
|
||||||
|
.PARAMETER SourcePath
|
||||||
|
Ordner, der die Sicherung enthaelt (der Ordner, der "StampsBackup" enthaelt).
|
||||||
|
.EXAMPLE
|
||||||
|
.\Adobe-Stamps-Restore.ps1 -SourcePath "D:\Sicherung\AdobeStamps"
|
||||||
|
#>
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string]$SourcePath
|
||||||
|
)
|
||||||
|
|
||||||
|
# Pruefen, ob der Sicherungspfad existiert
|
||||||
|
if (-not (Test-Path $SourcePath)) {
|
||||||
|
Write-Error "Der angegebene Wiederherstellungspfad '$SourcePath' existiert nicht."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Lokaler Pfad zum Adobe Stamps-Ordner
|
||||||
|
$adobeStampsPath = Join-Path $env:APPDATA "Adobe\Acrobat\DC\Stamps"
|
||||||
|
|
||||||
|
# Quell-Ordner mit den gesicherten Stempeln
|
||||||
|
$backupFolder = Join-Path $SourcePath "StampsBackup"
|
||||||
|
|
||||||
|
# Pruefen, ob die Sicherung vorhanden ist
|
||||||
|
if (-not (Test-Path $backupFolder)) {
|
||||||
|
Write-Error "Der Sicherungsordner '$backupFolder' wurde nicht gefunden. Ist dies ein gueltiger Sicherungsordner?"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Zielordner sicherstellen (falls Chrome/Adobe neu installiert wurde)
|
||||||
|
if (-not (Test-Path $adobeStampsPath)) {
|
||||||
|
New-Item -Path $adobeStampsPath -ItemType Directory -Force | Out-Null
|
||||||
|
Write-Host "Der Adobe Stamps-Ordner '$adobeStampsPath' wurde erstellt."
|
||||||
|
}
|
||||||
|
|
||||||
|
# 1. Adobe Prozesse beenden, falls geöffnet (zwingend erforderlich, damit Dateien überschrieben werden können)
|
||||||
|
$adobeProcesses = Get-Process -Name "AcroRd32","Acrobat","AcrobatDC" -ErrorAction SilentlyContinue
|
||||||
|
if (-not $adobeProcesses) {
|
||||||
|
# Fallback: alle Prozesse mit "Acrobat" oder "AcroRd" im Namen suchen
|
||||||
|
$adobeProcesses = Get-Process | Where-Object { $_.ProcessName -match "Acrobat|AcroRd" }
|
||||||
|
}
|
||||||
|
if ($adobeProcesses) {
|
||||||
|
Write-Host "Adobe Acrobat/Reader ist geöffnet. Schließe Adobe, um Datenkorruption zu vermeiden..."
|
||||||
|
$adobeProcesses | Stop-Process -Force
|
||||||
|
Start-Sleep -Seconds 2 # Kurze Pause für sauberen Abschluss
|
||||||
|
}
|
||||||
|
|
||||||
|
# 2. Dateien und Ordner aus der Sicherung zurueckkopieren
|
||||||
|
$stamps = Get-ChildItem -Path $backupFolder -Force
|
||||||
|
foreach ($item in $stamps) {
|
||||||
|
$targetPath = Join-Path $adobeStampsPath $item.Name
|
||||||
|
|
||||||
|
if ($item.PSIsContainer) {
|
||||||
|
# Es ist ein Ordner (z.B. Dynamic) -> rekursiv kopieren/erstellen
|
||||||
|
if (Test-Path $targetPath) {
|
||||||
|
Copy-Item -Path $item.FullName -Destination $adobeStampsPath -Force -Recurse -ErrorAction Stop
|
||||||
|
} else {
|
||||||
|
Copy-Item -Path $item.FullName -Destination $adobeStampsPath -Force -Recurse -ErrorAction Stop
|
||||||
|
}
|
||||||
|
Write-Host " Ordner '$($item.Name)' wiederhergestellt."
|
||||||
|
} else {
|
||||||
|
# Es ist eine Datei (Stamp PDF)
|
||||||
|
Copy-Item -Path $item.FullName -Destination $targetPath -Force -ErrorAction Stop
|
||||||
|
Write-Host " Datei '$($item.Name)' wiederhergestellt."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$restoredCount = ($stamps | Measure-Object).Count
|
||||||
|
Write-Host "Erfolgreich alle Adobe Stempel aus '$backupFolder' nach '$adobeStampsPath' wiederhergestellt."
|
||||||
|
Write-Host "Wiederhergestellte Elemente: $restoredCount"
|
||||||
|
Write-Host "Du kannst Adobe Acrobat jetzt wieder starten."
|
||||||
|
|
||||||
|
# Hinweis: Adobe Stempel werden beim nächsten Start neu geladen
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Hinweis: Die Stempel werden beim nächsten Start von Adobe Acrobat automatisch neu geladen."
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error "Fehler bei der Wiederherstellung der Adobe Stempel: $_"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user