{"id":52,"date":"2016-05-03T09:02:14","date_gmt":"2016-05-03T16:02:14","guid":{"rendered":"http:\/\/vicds.myds.me\/wordpress\/?p=52"},"modified":"2020-08-21T13:23:06","modified_gmt":"2020-08-21T20:23:06","slug":"pserrorhandling","status":"publish","type":"post","link":"https:\/\/www.vscrypt.com\/pserrorhandling\/","title":{"rendered":"Error Handling in Windows PowerShell Scripts"},"content":{"rendered":"\n<p>Windows PowerShell is a very powerful and extremely useful tool in today&#8217;s IT. &nbsp;But when it comes to complex PowerShell scripts to automate tasks to make your job a little easier, handling errors properly will go a long way. &nbsp;Error handling shouldn&#8217;t just be limited to big and complex scripts, short scripts benefit a lot also if unexpected events are handled properly so things don&#8217;t go south.<\/p>\n\n\n\n<p>There are two types of errors you should worry about in PowerShell &#8212; <strong>Terminating<\/strong> and <strong>Non-terminating<\/strong> errors. &nbsp;Terminating errors are serious errors during execution that brings the script to a complete stop. &nbsp;Some examples of this are non-existent cmdlets, syntax errors or other fatal errors. &nbsp;Non-terminating errors, on the other hand, are not so serious errors that allow execution to continue despite failures. &nbsp;Examples of this are file not found errors or permission issues. &nbsp;Non-terminating errors cannot be caught by default but you can treat them as terminating errors to catch and do something about them. &nbsp;You can also catch specific exceptions in which case you would like to perform specific actions, but you will&nbsp;have to know the name of the exceptions to catch them individually (no examples are provided because these are not common).<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Try, Catch and Finally Blocks<\/h2>\n\n\n\n<p>The <code>Try<\/code> block defines a section of a script to be monitored for errors. \u00a0That means, if an error occurs within the <code>Try<\/code> block, it is first saved to the <code>$Error<\/code> automatic variable. \u00a0PowerShell will then search for a <code>Catch<\/code> block that handles the error properly. \u00a0If a matching <code>Catch<\/code> block is not found, PowerShell will continue to search for it in the parent scope.<\/p>\n\n\n\n<p>After a <code>Catch<\/code> block completes or if no matching <code>Catch<\/code> block or Trap statement is found, it continues to the <code>Finally<\/code> block (if used). \u00a0Use the <code>Finally<\/code> block to free resources used by a script after the <code>Try<\/code> and <code>Catch<\/code> blocks. \u00a0The <code>Finally<\/code> block runs whether the script inside the <code>Try<\/code> block fails or not. \u00a0It also runs if <code>CTRL+C<\/code> is used to stop the script or if an <code>Exit<\/code> keyword stops the script from within a <code>Catch<\/code> block.<\/p><div id=\"vscry-0\" class=\"vscry-content\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-0201055796701118\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-client=\"ca-pub-0201055796701118\" \ndata-ad-slot=\"1379369629\" \ndata-ad-layout=\"in-article\"\ndata-ad-format=\"fluid\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Examples<\/h2>\n\n\n\n<h2 class=\"has-normal-font-size wp-block-heading\">Catching a Non-Terminating Error<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PowerShell\" data-shcb-language-slug=\"powershell\"><span><code class=\"hljs language-powershell\"><span class=\"hljs-variable\">$strUsers<\/span> = <span class=\"hljs-built_in\">Get-Content<\/span> <span class=\"hljs-string\">\"C:\\UserList.txt\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PowerShell<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">powershell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example, we are attempting to read a file which may or may not exist. \u00a0If the file does not exist, PowerShell will still continue the execution of the script but without values in the <code>$strUsers<\/code> variable, it may fail later. \u00a0So to force PowerShell to treat this as a Terminating error, you need to tell it using the <code>ErrorAction<\/code>\u00a0parameter. \u00a0By specifying <code>-ErrorAction Stop<\/code>, you ensure that all errors that are thrown by the cmdlet are caught.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PowerShell\" data-shcb-language-slug=\"powershell\"><span><code class=\"hljs language-powershell\"><span class=\"hljs-variable\">$strUsers<\/span> = <span class=\"hljs-built_in\">Get-Content<\/span> <span class=\"hljs-string\">\"C:\\UserList.txt\"<\/span> <span class=\"hljs-literal\">-ErrorAction<\/span> Stop<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PowerShell<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">powershell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"has-normal-font-size wp-block-heading\">Catching a Terminating Error<\/h2>\n\n\n\n<p>Continuing from the previous example, we are attempting to read a file which may or may not exist, this is how we would structure the <code>Try<\/code> and <code>Catch<\/code> blocks. &nbsp;We put the attempt to read the file inside the <code>Try<\/code> block and in case it fails we send an email message notifying someone that it failed from the <code>Catch<\/code> block which then terminates the script.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PowerShell\" data-shcb-language-slug=\"powershell\"><span><code class=\"hljs language-powershell shcb-code-table shcb-wrap-lines\"><mark class='shcb-loc'><span><span class=\"hljs-keyword\">Try<\/span>\n<\/span><\/mark><span class='shcb-loc'><span>{\n<\/span><\/span><span class='shcb-loc'><span>     <span class=\"hljs-variable\">$strUsers<\/span> = <span class=\"hljs-built_in\">Get-Content<\/span> <span class=\"hljs-string\">\"C:\\UserList.txt\"<\/span> <span class=\"hljs-literal\">-ErrorAction<\/span> Stop\n<\/span><\/span><span class='shcb-loc'><span>}\n<\/span><\/span><mark class='shcb-loc'><span><span class=\"hljs-keyword\">Catch<\/span>\n<\/span><\/mark><span class='shcb-loc'><span>{\n<\/span><\/span><span class='shcb-loc'><span>     <span class=\"hljs-built_in\">Send-MailMessage<\/span> <span class=\"hljs-literal\">-From<\/span> from@acme.com <span class=\"hljs-literal\">-To<\/span> to@acme.com <span class=\"hljs-literal\">-Subject<\/span> <span class=\"hljs-string\">\"File Read Failed!\"<\/span> <span class=\"hljs-literal\">-SmtpServer<\/span> mail.acme.com\n<\/span><\/span><span class='shcb-loc'><span>     <span class=\"hljs-keyword\">Break<\/span>\n<\/span><\/span><span class='shcb-loc'><span>}\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PowerShell<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">powershell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"has-normal-font-size wp-block-heading\">Using\u00a0a Finally Block<\/h2>\n\n\n\n<p>You can also add a <code>Finally<\/code> block after the <code>Catch<\/code> block to execute something that needs to run regardless of what happens inside the <code>Try<\/code> block. &nbsp;So here we get the current date and time stamp and output that to a log file so we can keep track of all the file read attempts.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PowerShell\" data-shcb-language-slug=\"powershell\"><span><code class=\"hljs language-powershell shcb-code-table shcb-wrap-lines\"><mark class='shcb-loc'><span><span class=\"hljs-keyword\">Try<\/span>\n<\/span><\/mark><span class='shcb-loc'><span>{\n<\/span><\/span><span class='shcb-loc'><span>     <span class=\"hljs-variable\">$strUsers<\/span> = <span class=\"hljs-built_in\">Get-Content<\/span> <span class=\"hljs-string\">\"C:\\UserList.txt\"<\/span> <span class=\"hljs-literal\">-ErrorAction<\/span> Stop\n<\/span><\/span><span class='shcb-loc'><span>}\n<\/span><\/span><mark class='shcb-loc'><span><span class=\"hljs-keyword\">Catch<\/span>\n<\/span><\/mark><span class='shcb-loc'><span>{\n<\/span><\/span><span class='shcb-loc'><span>     <span class=\"hljs-built_in\">Send-MailMessage<\/span> <span class=\"hljs-literal\">-From<\/span> from@acme.com <span class=\"hljs-literal\">-To<\/span> to@acme.com <span class=\"hljs-literal\">-Subject<\/span> <span class=\"hljs-string\">\"File Read Failed!\"<\/span> <span class=\"hljs-literal\">-SmtpServer<\/span> mail.acme.com\n<\/span><\/span><span class='shcb-loc'><span>     <span class=\"hljs-keyword\">Break<\/span>\n<\/span><\/span><span class='shcb-loc'><span>}\n<\/span><\/span><mark class='shcb-loc'><span><span class=\"hljs-keyword\">Finally<\/span>\n<\/span><\/mark><span class='shcb-loc'><span>{\n<\/span><\/span><span class='shcb-loc'><span>     <span class=\"hljs-variable\">$execTime<\/span> = <span class=\"hljs-built_in\">Get-Date<\/span> <span class=\"hljs-string\">\"File read attempt at <span class=\"hljs-variable\">$execTime<\/span>\"<\/span> | <span class=\"hljs-built_in\">Out-File<\/span> c:\\logs\\userlist.log <span class=\"hljs-literal\">-append<\/span>\n<\/span><\/span><span class='shcb-loc'><span>}\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PowerShell<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">powershell<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Windows PowerShell is a very powerful and extremely useful tool in today&#8217;s IT. &nbsp;But when it comes to complex PowerShell scripts to automate tasks to &hellip; <\/p>\n","protected":false},"author":1,"featured_media":79,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[11,12,14,9,13],"class_list":["post-52","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ps","category-scripts","tag-cmdlet","tag-error","tag-error-handling","tag-powershell","tag-try-catch-finally"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Error Handling in Windows PowerShell Scripts - VScrypt<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vscrypt.com\/pserrorhandling\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Error Handling in Windows PowerShell Scripts - VScrypt\" \/>\n<meta property=\"og:description\" content=\"Windows PowerShell is a very powerful and extremely useful tool in today&#8217;s IT. &nbsp;But when it comes to complex PowerShell scripts to automate tasks to &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vscrypt.com\/pserrorhandling\/\" \/>\n<meta property=\"og:site_name\" content=\"VScrypt\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-03T16:02:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-08-21T20:23:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/05\/download-e1462293817855.png\" \/>\n\t<meta property=\"og:image:width\" content=\"778\" \/>\n\t<meta property=\"og:image:height\" content=\"248\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Vikram\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vikram\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.vscrypt.com\/pserrorhandling\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.vscrypt.com\/pserrorhandling\/\"},\"author\":{\"name\":\"Vikram\",\"@id\":\"https:\/\/www.vscrypt.com\/#\/schema\/person\/855a3e6d9310019d20f2da32115df36a\"},\"headline\":\"Error Handling in Windows PowerShell Scripts\",\"datePublished\":\"2016-05-03T16:02:14+00:00\",\"dateModified\":\"2020-08-21T20:23:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.vscrypt.com\/pserrorhandling\/\"},\"wordCount\":553,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.vscrypt.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.vscrypt.com\/pserrorhandling\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/05\/download-e1462293817855.png\",\"keywords\":[\"cmdlet\",\"error\",\"error handling\",\"powershell\",\"try-catch-finally\"],\"articleSection\":[\"PowerShell\",\"Scripts\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.vscrypt.com\/pserrorhandling\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vscrypt.com\/pserrorhandling\/\",\"url\":\"https:\/\/www.vscrypt.com\/pserrorhandling\/\",\"name\":\"Error Handling in Windows PowerShell Scripts - VScrypt\",\"isPartOf\":{\"@id\":\"https:\/\/www.vscrypt.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.vscrypt.com\/pserrorhandling\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.vscrypt.com\/pserrorhandling\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/05\/download-e1462293817855.png\",\"datePublished\":\"2016-05-03T16:02:14+00:00\",\"dateModified\":\"2020-08-21T20:23:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vscrypt.com\/pserrorhandling\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vscrypt.com\/pserrorhandling\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vscrypt.com\/pserrorhandling\/#primaryimage\",\"url\":\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/05\/download-e1462293817855.png\",\"contentUrl\":\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/05\/download-e1462293817855.png\",\"width\":778,\"height\":248,\"caption\":\"PowerShell Error\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vscrypt.com\/pserrorhandling\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vscrypt.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Error Handling in Windows PowerShell Scripts\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vscrypt.com\/#website\",\"url\":\"https:\/\/www.vscrypt.com\/\",\"name\":\"VScrypt\",\"description\":\"Helpful scripts, snippets and guides...\",\"publisher\":{\"@id\":\"https:\/\/www.vscrypt.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vscrypt.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vscrypt.com\/#organization\",\"name\":\"VScrypt\",\"url\":\"https:\/\/www.vscrypt.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vscrypt.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2019\/01\/logo-1.png\",\"contentUrl\":\"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2019\/01\/logo-1.png\",\"width\":200,\"height\":80,\"caption\":\"VScrypt\"},\"image\":{\"@id\":\"https:\/\/www.vscrypt.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.vscrypt.com\/#\/schema\/person\/855a3e6d9310019d20f2da32115df36a\",\"name\":\"Vikram\",\"description\":\"I am just an IT person trying to share as much knowledge as possible hoping someone will find it helpful. It just takes time to organize everything from my head into something that makes sense.\",\"url\":\"https:\/\/www.vscrypt.com\/author\/vchand\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Error Handling in Windows PowerShell Scripts - VScrypt","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vscrypt.com\/pserrorhandling\/","og_locale":"en_US","og_type":"article","og_title":"Error Handling in Windows PowerShell Scripts - VScrypt","og_description":"Windows PowerShell is a very powerful and extremely useful tool in today&#8217;s IT. &nbsp;But when it comes to complex PowerShell scripts to automate tasks to &hellip;","og_url":"https:\/\/www.vscrypt.com\/pserrorhandling\/","og_site_name":"VScrypt","article_published_time":"2016-05-03T16:02:14+00:00","article_modified_time":"2020-08-21T20:23:06+00:00","og_image":[{"width":778,"height":248,"url":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/05\/download-e1462293817855.png","type":"image\/png"}],"author":"Vikram","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Vikram","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.vscrypt.com\/pserrorhandling\/#article","isPartOf":{"@id":"https:\/\/www.vscrypt.com\/pserrorhandling\/"},"author":{"name":"Vikram","@id":"https:\/\/www.vscrypt.com\/#\/schema\/person\/855a3e6d9310019d20f2da32115df36a"},"headline":"Error Handling in Windows PowerShell Scripts","datePublished":"2016-05-03T16:02:14+00:00","dateModified":"2020-08-21T20:23:06+00:00","mainEntityOfPage":{"@id":"https:\/\/www.vscrypt.com\/pserrorhandling\/"},"wordCount":553,"commentCount":0,"publisher":{"@id":"https:\/\/www.vscrypt.com\/#organization"},"image":{"@id":"https:\/\/www.vscrypt.com\/pserrorhandling\/#primaryimage"},"thumbnailUrl":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/05\/download-e1462293817855.png","keywords":["cmdlet","error","error handling","powershell","try-catch-finally"],"articleSection":["PowerShell","Scripts"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.vscrypt.com\/pserrorhandling\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.vscrypt.com\/pserrorhandling\/","url":"https:\/\/www.vscrypt.com\/pserrorhandling\/","name":"Error Handling in Windows PowerShell Scripts - VScrypt","isPartOf":{"@id":"https:\/\/www.vscrypt.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.vscrypt.com\/pserrorhandling\/#primaryimage"},"image":{"@id":"https:\/\/www.vscrypt.com\/pserrorhandling\/#primaryimage"},"thumbnailUrl":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/05\/download-e1462293817855.png","datePublished":"2016-05-03T16:02:14+00:00","dateModified":"2020-08-21T20:23:06+00:00","breadcrumb":{"@id":"https:\/\/www.vscrypt.com\/pserrorhandling\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vscrypt.com\/pserrorhandling\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vscrypt.com\/pserrorhandling\/#primaryimage","url":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/05\/download-e1462293817855.png","contentUrl":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2016\/05\/download-e1462293817855.png","width":778,"height":248,"caption":"PowerShell Error"},{"@type":"BreadcrumbList","@id":"https:\/\/www.vscrypt.com\/pserrorhandling\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vscrypt.com\/"},{"@type":"ListItem","position":2,"name":"Error Handling in Windows PowerShell Scripts"}]},{"@type":"WebSite","@id":"https:\/\/www.vscrypt.com\/#website","url":"https:\/\/www.vscrypt.com\/","name":"VScrypt","description":"Helpful scripts, snippets and guides...","publisher":{"@id":"https:\/\/www.vscrypt.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vscrypt.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vscrypt.com\/#organization","name":"VScrypt","url":"https:\/\/www.vscrypt.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vscrypt.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2019\/01\/logo-1.png","contentUrl":"https:\/\/www.vscrypt.com\/wp-content\/uploads\/2019\/01\/logo-1.png","width":200,"height":80,"caption":"VScrypt"},"image":{"@id":"https:\/\/www.vscrypt.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.vscrypt.com\/#\/schema\/person\/855a3e6d9310019d20f2da32115df36a","name":"Vikram","description":"I am just an IT person trying to share as much knowledge as possible hoping someone will find it helpful. It just takes time to organize everything from my head into something that makes sense.","url":"https:\/\/www.vscrypt.com\/author\/vchand\/"}]}},"_links":{"self":[{"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/comments?post=52"}],"version-history":[{"count":0,"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/posts\/52\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/media\/79"}],"wp:attachment":[{"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vscrypt.com\/api\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}