{"id":20,"date":"2025-12-26T18:53:55","date_gmt":"2025-12-26T17:53:55","guid":{"rendered":"https:\/\/www.bloy.info\/?p=20"},"modified":"2025-12-26T18:59:09","modified_gmt":"2025-12-26T17:59:09","slug":"powershell","status":"publish","type":"post","link":"https:\/\/www.bloy.info\/index.php\/2025\/12\/26\/powershell\/","title":{"rendered":"Powershell &#8211; schnell unsaubere Exporte"},"content":{"rendered":"\n<p>ein kleines Skript zur Sicherung aller Vms auf eine externe Festplatte.<\/p>\n\n\n\n<p>Wichtig: Das Verzeichnis muss existieren, ansonsten bricht das Skript ab<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Zielpfad auf externer Festplatte\n$ExportRoot = \"D:\\HyperV-Exports\"\n\n# Pr\u00fcfen ob Ziel existiert\nif (-not (Test-Path $ExportRoot)) {\n    Write-Error \"Zielpfad $ExportRoot existiert nicht. Abbruch.\"\n    exit 1\n}\n\n# Zeitstempel\n$Timestamp = Get-Date -Format \"yyyy-MM-dd_HH-mm-ss\"\n$ExportBase = Join-Path $ExportRoot \"Export_$Timestamp\"\n\n# Export-Basisverzeichnis anlegen\nNew-Item -ItemType Directory -Path $ExportBase | Out-Null\n\n# Alle VMs ermitteln\n$VMs = Get-VM\n\nif ($VMs.Count -eq 0) {\n    Write-Host \"Keine virtuellen Maschinen gefunden.\"\n    exit 0\n}\n\nforeach ($VM in $VMs) {\n    $VMExportPath = Join-Path $ExportBase $VM.Name\n\n    Write-Host \"Exportiere VM '$($VM.Name)' nach $VMExportPath ...\"\n    \n    try {\n        Export-VM -Name $VM.Name -Path $VMExportPath -ErrorAction Stop\n        Write-Host \"\u2713 Export von '$($VM.Name)' abgeschlossen.\"\n    }\n    catch {\n        Write-Error \"\u2717 Fehler beim Export von '$($VM.Name)': $_\"\n    }\n}\n\nWrite-Host \"Alle Exporte abgeschlossen.\"<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>ein kleines Skript zur Sicherung aller Vms auf eine externe Festplatte. Wichtig: Das Verzeichnis muss existieren, ansonsten bricht das Skript ab<\/p>\n","protected":false},"author":1,"featured_media":23,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-20","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-allgemein"],"_links":{"self":[{"href":"https:\/\/www.bloy.info\/index.php\/wp-json\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bloy.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bloy.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bloy.info\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bloy.info\/index.php\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":2,"href":"https:\/\/www.bloy.info\/index.php\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"predecessor-version":[{"id":22,"href":"https:\/\/www.bloy.info\/index.php\/wp-json\/wp\/v2\/posts\/20\/revisions\/22"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bloy.info\/index.php\/wp-json\/wp\/v2\/media\/23"}],"wp:attachment":[{"href":"https:\/\/www.bloy.info\/index.php\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bloy.info\/index.php\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bloy.info\/index.php\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}