{"id":526,"date":"2008-07-23T06:00:07","date_gmt":"2008-07-23T14:00:07","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/2008\/07\/22\/fun-with-debug-messages\/"},"modified":"2008-07-22T04:43:27","modified_gmt":"2008-07-22T12:43:27","slug":"fun-with-debug-messages","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/","title":{"rendered":"Fun with Debug Messages"},"content":{"rendered":"<p>In my script and function development, I often add the line $DebugPreference=&quot;SilentlyContinue&quot; to the beginning of my code. Throughout the script I add lines using Write-Debug that tell me what the script is doing or the value of a particular variable. This has been very helpful. When I want to see the debug messages, I set $DebugPreference to &quot;Continue&quot; and voila!.&nbsp; In PrimalScript all the messages are written to the debug panel.&nbsp; But I wanted to do more than merely have a line like:<\/p>\n<p><font color=\"#0000ff\">write-debug &quot;creating user account&quot;<\/font><\/p>\n<p>I wanted to see more information like a time stamp or user credentials. I also found it difficult sometimes to pass object properties to the debug pipeline. So I came up with a function I call New-DebugMessage.<\/p>\n<div style=\"border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);\">\n<div style=\"border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);\">\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;\"><span style=\"color: rgb(96, 96, 96);\">   1:<\/span> Function New-DebugMessage {<\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);\"><span style=\"color: rgb(96, 96, 96);\">   2:<\/span>        Param([string]$text)<\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;\"><span style=\"color: rgb(96, 96, 96);\">   3:<\/span>        <\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);\"><span style=\"color: rgb(96, 96, 96);\">   4:<\/span>        <span style=\"color: rgb(0, 128, 0);\"># build a text string of information that can be passed<\/span><\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;\"><span style=\"color: rgb(96, 96, 96);\">   5:<\/span>        <span style=\"color: rgb(0, 128, 0);\"># to different pipelines like Debug<\/span><\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);\"><span style=\"color: rgb(96, 96, 96);\">   6:<\/span>        <\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;\"><span style=\"color: rgb(96, 96, 96);\">   7:<\/span>        <span style=\"color: rgb(0, 128, 0);\">#here are some variables you might want to work with<\/span><\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);\"><span style=\"color: rgb(96, 96, 96);\">   8:<\/span>        $computer=$env:computername<\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;\"><span style=\"color: rgb(96, 96, 96);\">   9:<\/span>        $domain=$env:userdomain<\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);\"><span style=\"color: rgb(96, 96, 96);\">  10:<\/span>        $user=$env:username<\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;\"><span style=\"color: rgb(96, 96, 96);\">  11:<\/span>        $timestamp=(Get-Date -Format g).toString()<\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);\"><span style=\"color: rgb(96, 96, 96);\">  12:<\/span>        $line=$($myinvocation.scriptlinenumber)<\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;\"><span style=\"color: rgb(96, 96, 96);\">  13:<\/span>        $<span style=\"color: rgb(0, 0, 255);\">script<\/span>=$($myinvocation.invocationname)<\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);\"><span style=\"color: rgb(96, 96, 96);\">  14:<\/span>        <\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;\"><span style=\"color: rgb(96, 96, 96);\">  15:<\/span>        [string]$msg=<span style=\"color: rgb(0, 96, 128);\">&quot;[{0}:{1}\\{2}] {3} Line:{4} {5}&quot;<\/span> -f $computer,$domain,$user,$timestamp,$line,$text<\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);\"><span style=\"color: rgb(96, 96, 96);\">  16:<\/span>        <\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;\"><span style=\"color: rgb(96, 96, 96);\">  17:<\/span>        write $msg<\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);\"><span style=\"color: rgb(96, 96, 96);\">  18:<\/span>    <\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;\"><span style=\"color: rgb(96, 96, 96);\">  19:<\/span>    }<\/pre>\n<pre style=\"border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);\"><span style=\"color: rgb(96, 96, 96);\">  20:<\/span>  <\/pre>\n<\/div>\n<\/div>\n<p>The function returns a string that can be used by Write-Debug:<\/p>\n<p><font color=\"#0000ff\">Write-Debug (New-DebugMessage &quot;Getting powershell process&quot;)<\/font><\/p>\n<p>The string is passed to the function. Within the function I&#8217;ve set some variables that you might find handy in your debug message. Most of them should be self-explanatory. The $line variable will display the line number of your script where the Write-Debug message occurs. If you place your Write-Debug command before key commands, it should be easy to jump to those sections.<\/p>\n<p>Here&#8217;s a short script that I tested this with.<\/p>\n<p><font color=\"#0000ff\">$debugpreference=&quot;continue&quot; <\/font><\/p>\n<p><font color=\"#0000ff\">Write-Debug (New-DebugMessage &quot;starting $($myinvocation.invocationname)&quot;)<br \/>\nWrite-Debug (New-DebugMessage &quot;Getting Date&quot;)<br \/>\nGet-Date<br \/>\nWrite-Debug (New-DebugMessage &quot;Getting powershell process&quot;)<br \/>\nGet-Process powershell<br \/>\nWrite-Debug (New-DebugMessage &quot;finished&quot;)<\/font><\/p>\n<p>When I run the script I get this output (click the image for a larger view):<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2008\/07\/debug.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" height=\"79\" border=\"0\" width=\"244\" style=\"border: 0px none ;\" alt=\"debug\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2008\/07\/debug-thumb.png\" \/><\/a><\/p>\n<p>Does this look useful to you?&nbsp; What other things would you like to add or did you add to your debug messages?<\/p>\n<div class=\"wlWriterSmartContent\" id=\"scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:0b4cf4e4-3920-40bb-b7df-9729660c9416\" style=\"margin: 0px; padding: 0px; display: inline;\">\n<p>Download the function <a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2008\/07\/new-debugmessage.txt\" target=\"_blank\">here.<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In my script and function development, I often add the line $DebugPreference=&#8221;SilentlyContinue&#8221; to the beginning of my code. Throughout the script I add lines using Write-Debug that tell me what the script is doing or the value of a particular variable. This has been very helpful. When I want to see the debug messages, I set $DebugPreference to &#8220;Continue&#8221; and voila!.  In PrimalScript all the messages are written to the debug panel.  But I wanted more .<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[25],"tags":[222,198,28,57,255],"class_list":["post-526","post","type-post","status-publish","format-standard","hentry","category-windows-powershell","tag-debugging","tag-function","tag-powershell","tag-scripting","tag-write-debug"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"In my script and function development, I often add the line $DebugPreference=&quot;SilentlyContinue&quot; to the beginning of my code. Throughout the script I add lines using Write-Debug that tell me what the script is doing or the value of a particular variable. This has been very helpful. When I want to see the debug messages, I set $DebugPreference to &quot;Continue&quot; and voila!. In PrimalScript all the messages are written to the debug panel. But I wanted more .\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Jeffery Hicks\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"DEV SAPIEN Blog - Tools for IT Success\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Fun with Debug Messages - DEV SAPIEN Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"In my script and function development, I often add the line $DebugPreference=&quot;SilentlyContinue&quot; to the beginning of my code. Throughout the script I add lines using Write-Debug that tell me what the script is doing or the value of a particular variable. This has been very helpful. When I want to see the debug messages, I set $DebugPreference to &quot;Continue&quot; and voila!. In PrimalScript all the messages are written to the debug panel. But I wanted more .\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2008-07-23T14:00:07+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2008-07-22T12:43:27+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Fun with Debug Messages - DEV SAPIEN Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"In my script and function development, I often add the line $DebugPreference=&quot;SilentlyContinue&quot; to the beginning of my code. Throughout the script I add lines using Write-Debug that tell me what the script is doing or the value of a particular variable. This has been very helpful. When I want to see the debug messages, I set $DebugPreference to &quot;Continue&quot; and voila!. In PrimalScript all the messages are written to the debug panel. But I wanted more .\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2008\\\/07\\\/23\\\/fun-with-debug-messages\\\/#blogposting\",\"name\":\"Fun with Debug Messages - DEV SAPIEN Blog\",\"headline\":\"Fun with Debug Messages\",\"author\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/jeffery-hicks\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"http:\\\/\\\/www.sapien.com\\\/blog\\\/wp-content\\\/uploads\\\/2008\\\/07\\\/debug-thumb.png\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2008\\\/07\\\/23\\\/fun-with-debug-messages\\\/#articleImage\"},\"datePublished\":\"2008-07-23T06:00:07-07:00\",\"dateModified\":\"2008-07-22T04:43:27-07:00\",\"inLanguage\":\"en-US\",\"commentCount\":5,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2008\\\/07\\\/23\\\/fun-with-debug-messages\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2008\\\/07\\\/23\\\/fun-with-debug-messages\\\/#webpage\"},\"articleSection\":\"Windows PowerShell, Debugging, function, powershell, scripting, Write-Debug\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2008\\\/07\\\/23\\\/fun-with-debug-messages\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/dev.sapien.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/windows-powershell\\\/#listItem\",\"name\":\"Windows PowerShell\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/windows-powershell\\\/#listItem\",\"position\":2,\"name\":\"Windows PowerShell\",\"item\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/windows-powershell\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2008\\\/07\\\/23\\\/fun-with-debug-messages\\\/#listItem\",\"name\":\"Fun with Debug Messages\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2008\\\/07\\\/23\\\/fun-with-debug-messages\\\/#listItem\",\"position\":3,\"name\":\"Fun with Debug Messages\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/windows-powershell\\\/#listItem\",\"name\":\"Windows PowerShell\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\",\"name\":\"DEV SAPIEN Blog\",\"description\":\"Tools for IT Success\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/jeffery-hicks\\\/#author\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/jeffery-hicks\\\/\",\"name\":\"Jeffery Hicks\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2008\\\/07\\\/23\\\/fun-with-debug-messages\\\/#webpage\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2008\\\/07\\\/23\\\/fun-with-debug-messages\\\/\",\"name\":\"Fun with Debug Messages - DEV SAPIEN Blog\",\"description\":\"In my script and function development, I often add the line $DebugPreference=\\\"SilentlyContinue\\\" to the beginning of my code. Throughout the script I add lines using Write-Debug that tell me what the script is doing or the value of a particular variable. This has been very helpful. When I want to see the debug messages, I set $DebugPreference to \\\"Continue\\\" and voila!. In PrimalScript all the messages are written to the debug panel. But I wanted more .\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2008\\\/07\\\/23\\\/fun-with-debug-messages\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/jeffery-hicks\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/jeffery-hicks\\\/#author\"},\"datePublished\":\"2008-07-23T06:00:07-07:00\",\"dateModified\":\"2008-07-22T04:43:27-07:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/\",\"name\":\"DEV SAPIEN Blog\",\"description\":\"Tools for IT Success\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Fun with Debug Messages - DEV SAPIEN Blog","description":"In my script and function development, I often add the line $DebugPreference=\"SilentlyContinue\" to the beginning of my code. Throughout the script I add lines using Write-Debug that tell me what the script is doing or the value of a particular variable. This has been very helpful. When I want to see the debug messages, I set $DebugPreference to \"Continue\" and voila!. In PrimalScript all the messages are written to the debug panel. But I wanted more .","canonical_url":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/#blogposting","name":"Fun with Debug Messages - DEV SAPIEN Blog","headline":"Fun with Debug Messages","author":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/jeffery-hicks\/#author"},"publisher":{"@id":"https:\/\/dev.sapien.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2008\/07\/debug-thumb.png","@id":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/#articleImage"},"datePublished":"2008-07-23T06:00:07-07:00","dateModified":"2008-07-22T04:43:27-07:00","inLanguage":"en-US","commentCount":5,"mainEntityOfPage":{"@id":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/#webpage"},"isPartOf":{"@id":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/#webpage"},"articleSection":"Windows PowerShell, Debugging, function, powershell, scripting, Write-Debug"},{"@type":"BreadcrumbList","@id":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/dev.sapien.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/windows-powershell\/#listItem","name":"Windows PowerShell"}},{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/windows-powershell\/#listItem","position":2,"name":"Windows PowerShell","item":"https:\/\/dev.sapien.com\/blog\/topics\/windows-powershell\/","nextItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/#listItem","name":"Fun with Debug Messages"},"previousItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/#listItem","position":3,"name":"Fun with Debug Messages","previousItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/windows-powershell\/#listItem","name":"Windows PowerShell"}}]},{"@type":"Organization","@id":"https:\/\/dev.sapien.com\/blog\/#organization","name":"DEV SAPIEN Blog","description":"Tools for IT Success","url":"https:\/\/dev.sapien.com\/blog\/"},{"@type":"Person","@id":"https:\/\/dev.sapien.com\/blog\/author\/jeffery-hicks\/#author","url":"https:\/\/dev.sapien.com\/blog\/author\/jeffery-hicks\/","name":"Jeffery Hicks"},{"@type":"WebPage","@id":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/#webpage","url":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/","name":"Fun with Debug Messages - DEV SAPIEN Blog","description":"In my script and function development, I often add the line $DebugPreference=\"SilentlyContinue\" to the beginning of my code. Throughout the script I add lines using Write-Debug that tell me what the script is doing or the value of a particular variable. This has been very helpful. When I want to see the debug messages, I set $DebugPreference to \"Continue\" and voila!. In PrimalScript all the messages are written to the debug panel. But I wanted more .","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/dev.sapien.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/#breadcrumblist"},"author":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/jeffery-hicks\/#author"},"creator":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/jeffery-hicks\/#author"},"datePublished":"2008-07-23T06:00:07-07:00","dateModified":"2008-07-22T04:43:27-07:00"},{"@type":"WebSite","@id":"https:\/\/dev.sapien.com\/blog\/#website","url":"https:\/\/dev.sapien.com\/blog\/","name":"DEV SAPIEN Blog","description":"Tools for IT Success","inLanguage":"en-US","publisher":{"@id":"https:\/\/dev.sapien.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"DEV SAPIEN Blog - Tools for IT Success","og:type":"article","og:title":"Fun with Debug Messages - DEV SAPIEN Blog","og:description":"In my script and function development, I often add the line $DebugPreference=&quot;SilentlyContinue&quot; to the beginning of my code. Throughout the script I add lines using Write-Debug that tell me what the script is doing or the value of a particular variable. This has been very helpful. When I want to see the debug messages, I set $DebugPreference to &quot;Continue&quot; and voila!. In PrimalScript all the messages are written to the debug panel. But I wanted more .","og:url":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/","article:published_time":"2008-07-23T14:00:07+00:00","article:modified_time":"2008-07-22T12:43:27+00:00","twitter:card":"summary_large_image","twitter:title":"Fun with Debug Messages - DEV SAPIEN Blog","twitter:description":"In my script and function development, I often add the line $DebugPreference=&quot;SilentlyContinue&quot; to the beginning of my code. Throughout the script I add lines using Write-Debug that tell me what the script is doing or the value of a particular variable. This has been very helpful. When I want to see the debug messages, I set $DebugPreference to &quot;Continue&quot; and voila!. In PrimalScript all the messages are written to the debug panel. But I wanted more ."},"aioseo_meta_data":{"post_id":"526","title":null,"description":null,"keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":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_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"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,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-08-28 14:27:50","updated":"2026-08-28 14:27:50"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dev.sapien.com\/blog\" 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:\/\/dev.sapien.com\/blog\/topics\/windows-powershell\/\" title=\"Windows PowerShell\">Windows PowerShell<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tFun with Debug Messages\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/dev.sapien.com\/blog"},{"label":"Windows PowerShell","link":"https:\/\/dev.sapien.com\/blog\/topics\/windows-powershell\/"},{"label":"Fun with Debug Messages","link":"https:\/\/dev.sapien.com\/blog\/2008\/07\/23\/fun-with-debug-messages\/"}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=526"}],"version-history":[{"count":3,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/526\/revisions"}],"predecessor-version":[{"id":570,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/526\/revisions\/570"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}