{"id":59,"date":"2013-08-05T15:26:39","date_gmt":"2013-08-05T13:26:39","guid":{"rendered":"http:\/\/ps.stefanrehwald.de\/?p=59"},"modified":"2013-08-05T16:32:02","modified_gmt":"2013-08-05T14:32:02","slug":"powershell-fehler-abfangen-error-handling","status":"publish","type":"post","link":"https:\/\/ps.stefanrehwald.de\/?p=59","title":{"rendered":"PowerShell &#8211; Fehler abfangen, Error Handling"},"content":{"rendered":"<p style=\"text-align: justify;\">Fehler k\u00f6nnten mittels Try Catch angefangen werden. Der Script-Code wird im Try-Block ausgef\u00fchrt. Im Fehlerfall st\u00fcrzt das Script nicht ab, sonder f\u00fchrt den Catch-Block aus. Hier kann auch der Fehler-Coder oder die Fehlerbeschreibung ausgegeben werden.<\/p>\n<pre class=\"lang:ps decode:true\" title=\"Try-Catch Script\">try\r\n{\r\n  # F\u00fchre einen Code aus...\r\n}\r\n\r\ncatch  \r\n{\r\n    $ErrorMessage = $_.Exception.Message\r\n    $FailedItem = $_.Exception.ItemName\r\n    Write-Host $ErrorMessage + \" \" + $FailedItem<\/pre>\n<p>&nbsp;<\/p>\n<p>rewe<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fehler k\u00f6nnten mittels Try Catch angefangen werden. Der Script-Code wird im Try-Block ausgef\u00fchrt. Im Fehlerfall st\u00fcrzt das Script nicht ab, sonder f\u00fchrt den Catch-Block aus. Hier kann auch der Fehler-Coder oder die Fehlerbeschreibung ausgegeben werden. try { # F\u00fchre einen &hellip; <a href=\"https:\/\/ps.stefanrehwald.de\/?p=59\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":8,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[2,9],"tags":[12,14,15,16,11,17,13],"class_list":["post-59","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","category-snippet","tag-catch","tag-error-handling","tag-fehler","tag-fehler-abfangen","tag-try","tag-try-catch","tag-try-catch-error"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"Einen Fehler mitels Try-Catch anfangen und bearbeiten.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Stefan Rehwald\"\/>\n\t<meta name=\"keywords\" content=\"try,catch,try-catch. error,error handling,fehler,fehler abfangen,try catch,,catch,try,try catch\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/ps.stefanrehwald.de\/?p=59\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"de_DE\" \/>\n\t\t<meta property=\"og:site_name\" content=\"PowerShell Scripts | Eine Sammlung von PowerShell Snippets\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Fehler abfangen mit Try-Catch | PowerShell Scripts\" \/>\n\t\t<meta property=\"og:description\" content=\"Einen Fehler mitels Try-Catch anfangen und bearbeiten.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/ps.stefanrehwald.de\/?p=59\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2013-08-05T13:26:39+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2013-08-05T14:32:02+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Fehler abfangen mit Try-Catch | PowerShell Scripts\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Einen Fehler mitels Try-Catch anfangen und bearbeiten.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?p=59#article\",\"name\":\"Fehler abfangen mit Try-Catch | PowerShell Scripts\",\"headline\":\"PowerShell &#8211; Fehler abfangen, Error Handling\",\"author\":{\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?author=2#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/wp-content\\\/uploads\\\/2013\\\/08\\\/logo_powershell.jpg\",\"width\":244,\"height\":191,\"caption\":\"PowerShell 3.0\"},\"datePublished\":\"2013-08-05T15:26:39+02:00\",\"dateModified\":\"2013-08-05T16:32:02+02:00\",\"inLanguage\":\"de-DE\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?p=59#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?p=59#webpage\"},\"articleSection\":\"PowerShell, Snippet, catch, error handling, Fehler, Fehler abfangen, try, Try Catch, Try-catch. error\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?p=59#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ps.stefanrehwald.de\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?cat=2#listItem\",\"name\":\"PowerShell\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?cat=2#listItem\",\"position\":2,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?cat=2\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?cat=9#listItem\",\"name\":\"Snippet\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?cat=9#listItem\",\"position\":3,\"name\":\"Snippet\",\"item\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?cat=9\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?p=59#listItem\",\"name\":\"PowerShell &#8211; Fehler abfangen, Error Handling\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?cat=2#listItem\",\"name\":\"PowerShell\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?p=59#listItem\",\"position\":4,\"name\":\"PowerShell &#8211; Fehler abfangen, Error Handling\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?cat=9#listItem\",\"name\":\"Snippet\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/#organization\",\"name\":\"PowerShell Scripts\",\"description\":\"Eine Sammlung von PowerShell Snippets\",\"url\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?author=2#author\",\"url\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?author=2\",\"name\":\"Stefan Rehwald\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?p=59#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/00349957f89eb7edc5bfe4e8d19b2198e56cb63116c2a4ac8ba0e6b8b8b75451?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Stefan Rehwald\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?p=59#webpage\",\"url\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?p=59\",\"name\":\"Fehler abfangen mit Try-Catch | PowerShell Scripts\",\"description\":\"Einen Fehler mitels Try-Catch anfangen und bearbeiten.\",\"inLanguage\":\"de-DE\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?p=59#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?author=2#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?author=2#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/wp-content\\\/uploads\\\/2013\\\/08\\\/logo_powershell.jpg\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?p=59\\\/#mainImage\",\"width\":244,\"height\":191,\"caption\":\"PowerShell 3.0\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/?p=59#mainImage\"},\"datePublished\":\"2013-08-05T15:26:39+02:00\",\"dateModified\":\"2013-08-05T16:32:02+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/#website\",\"url\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/\",\"name\":\"PowerShell Scripts\",\"description\":\"Eine Sammlung von PowerShell Snippets\",\"inLanguage\":\"de-DE\",\"publisher\":{\"@id\":\"https:\\\/\\\/ps.stefanrehwald.de\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Fehler abfangen mit Try-Catch | PowerShell Scripts","description":"Einen Fehler mitels Try-Catch anfangen und bearbeiten.","canonical_url":"https:\/\/ps.stefanrehwald.de\/?p=59","robots":"max-image-preview:large","keywords":"try,catch,try-catch. error,error handling,fehler,fehler abfangen,try catch,,catch,try,try catch","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ps.stefanrehwald.de\/?p=59#article","name":"Fehler abfangen mit Try-Catch | PowerShell Scripts","headline":"PowerShell &#8211; Fehler abfangen, Error Handling","author":{"@id":"https:\/\/ps.stefanrehwald.de\/?author=2#author"},"publisher":{"@id":"https:\/\/ps.stefanrehwald.de\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/ps.stefanrehwald.de\/wp-content\/uploads\/2013\/08\/logo_powershell.jpg","width":244,"height":191,"caption":"PowerShell 3.0"},"datePublished":"2013-08-05T15:26:39+02:00","dateModified":"2013-08-05T16:32:02+02:00","inLanguage":"de-DE","mainEntityOfPage":{"@id":"https:\/\/ps.stefanrehwald.de\/?p=59#webpage"},"isPartOf":{"@id":"https:\/\/ps.stefanrehwald.de\/?p=59#webpage"},"articleSection":"PowerShell, Snippet, catch, error handling, Fehler, Fehler abfangen, try, Try Catch, Try-catch. error"},{"@type":"BreadcrumbList","@id":"https:\/\/ps.stefanrehwald.de\/?p=59#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/ps.stefanrehwald.de#listItem","position":1,"name":"Home","item":"https:\/\/ps.stefanrehwald.de","nextItem":{"@type":"ListItem","@id":"https:\/\/ps.stefanrehwald.de\/?cat=2#listItem","name":"PowerShell"}},{"@type":"ListItem","@id":"https:\/\/ps.stefanrehwald.de\/?cat=2#listItem","position":2,"name":"PowerShell","item":"https:\/\/ps.stefanrehwald.de\/?cat=2","nextItem":{"@type":"ListItem","@id":"https:\/\/ps.stefanrehwald.de\/?cat=9#listItem","name":"Snippet"},"previousItem":{"@type":"ListItem","@id":"https:\/\/ps.stefanrehwald.de#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/ps.stefanrehwald.de\/?cat=9#listItem","position":3,"name":"Snippet","item":"https:\/\/ps.stefanrehwald.de\/?cat=9","nextItem":{"@type":"ListItem","@id":"https:\/\/ps.stefanrehwald.de\/?p=59#listItem","name":"PowerShell &#8211; Fehler abfangen, Error Handling"},"previousItem":{"@type":"ListItem","@id":"https:\/\/ps.stefanrehwald.de\/?cat=2#listItem","name":"PowerShell"}},{"@type":"ListItem","@id":"https:\/\/ps.stefanrehwald.de\/?p=59#listItem","position":4,"name":"PowerShell &#8211; Fehler abfangen, Error Handling","previousItem":{"@type":"ListItem","@id":"https:\/\/ps.stefanrehwald.de\/?cat=9#listItem","name":"Snippet"}}]},{"@type":"Organization","@id":"https:\/\/ps.stefanrehwald.de\/#organization","name":"PowerShell Scripts","description":"Eine Sammlung von PowerShell Snippets","url":"https:\/\/ps.stefanrehwald.de\/"},{"@type":"Person","@id":"https:\/\/ps.stefanrehwald.de\/?author=2#author","url":"https:\/\/ps.stefanrehwald.de\/?author=2","name":"Stefan Rehwald","image":{"@type":"ImageObject","@id":"https:\/\/ps.stefanrehwald.de\/?p=59#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/00349957f89eb7edc5bfe4e8d19b2198e56cb63116c2a4ac8ba0e6b8b8b75451?s=96&d=mm&r=g","width":96,"height":96,"caption":"Stefan Rehwald"}},{"@type":"WebPage","@id":"https:\/\/ps.stefanrehwald.de\/?p=59#webpage","url":"https:\/\/ps.stefanrehwald.de\/?p=59","name":"Fehler abfangen mit Try-Catch | PowerShell Scripts","description":"Einen Fehler mitels Try-Catch anfangen und bearbeiten.","inLanguage":"de-DE","isPartOf":{"@id":"https:\/\/ps.stefanrehwald.de\/#website"},"breadcrumb":{"@id":"https:\/\/ps.stefanrehwald.de\/?p=59#breadcrumblist"},"author":{"@id":"https:\/\/ps.stefanrehwald.de\/?author=2#author"},"creator":{"@id":"https:\/\/ps.stefanrehwald.de\/?author=2#author"},"image":{"@type":"ImageObject","url":"https:\/\/ps.stefanrehwald.de\/wp-content\/uploads\/2013\/08\/logo_powershell.jpg","@id":"https:\/\/ps.stefanrehwald.de\/?p=59\/#mainImage","width":244,"height":191,"caption":"PowerShell 3.0"},"primaryImageOfPage":{"@id":"https:\/\/ps.stefanrehwald.de\/?p=59#mainImage"},"datePublished":"2013-08-05T15:26:39+02:00","dateModified":"2013-08-05T16:32:02+02:00"},{"@type":"WebSite","@id":"https:\/\/ps.stefanrehwald.de\/#website","url":"https:\/\/ps.stefanrehwald.de\/","name":"PowerShell Scripts","description":"Eine Sammlung von PowerShell Snippets","inLanguage":"de-DE","publisher":{"@id":"https:\/\/ps.stefanrehwald.de\/#organization"}}]},"og:locale":"de_DE","og:site_name":"PowerShell Scripts | Eine Sammlung von PowerShell Snippets","og:type":"article","og:title":"Fehler abfangen mit Try-Catch | PowerShell Scripts","og:description":"Einen Fehler mitels Try-Catch anfangen und bearbeiten.","og:url":"https:\/\/ps.stefanrehwald.de\/?p=59","article:published_time":"2013-08-05T13:26:39+00:00","article:modified_time":"2013-08-05T14:32:02+00:00","twitter:card":"summary","twitter:title":"Fehler abfangen mit Try-Catch | PowerShell Scripts","twitter:description":"Einen Fehler mitels Try-Catch anfangen und bearbeiten."},"aioseo_meta_data":{"post_id":"59","title":"Fehler abfangen mit Try-Catch | #site_title","description":"Einen Fehler mitels Try-Catch anfangen und bearbeiten.","keywords":[{"label":"try,catch","value":"try,catch"},{"label":"Try-catch. error","value":"Try-catch. error"},{"label":"error handling","value":"error handling"},{"label":"Fehler","value":"Fehler"},{"label":"Fehler abfangen","value":"Fehler abfangen"},{"label":"Try Catch,","value":"Try Catch,"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2020-12-30 00:57:17","updated":"2025-10-06 08:58:45","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/ps.stefanrehwald.de\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/ps.stefanrehwald.de\/?cat=2\" title=\"PowerShell\">PowerShell<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/ps.stefanrehwald.de\/?cat=9\" title=\"Snippet\">Snippet<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tPowerShell \u2013 Fehler abfangen, Error Handling\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/ps.stefanrehwald.de"},{"label":"PowerShell","link":"https:\/\/ps.stefanrehwald.de\/?cat=2"},{"label":"Snippet","link":"https:\/\/ps.stefanrehwald.de\/?cat=9"},{"label":"PowerShell &#8211; Fehler abfangen, Error Handling","link":"https:\/\/ps.stefanrehwald.de\/?p=59"}],"jetpack_featured_media_url":"https:\/\/ps.stefanrehwald.de\/wp-content\/uploads\/2013\/08\/logo_powershell.jpg","jetpack_shortlink":"https:\/\/wp.me\/p3N2Ht-X","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ps.stefanrehwald.de\/index.php?rest_route=\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ps.stefanrehwald.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ps.stefanrehwald.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ps.stefanrehwald.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ps.stefanrehwald.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=59"}],"version-history":[{"count":2,"href":"https:\/\/ps.stefanrehwald.de\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":61,"href":"https:\/\/ps.stefanrehwald.de\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions\/61"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ps.stefanrehwald.de\/index.php?rest_route=\/wp\/v2\/media\/8"}],"wp:attachment":[{"href":"https:\/\/ps.stefanrehwald.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ps.stefanrehwald.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ps.stefanrehwald.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}