{"id":261,"date":"2014-12-01T11:59:00","date_gmt":"2014-12-01T11:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2014\/12\/01\/powertip-avoid-prompt-when-using-debug\/"},"modified":"2019-02-18T10:36:49","modified_gmt":"2019-02-18T17:36:49","slug":"powertip-avoid-prompt-when-using-debug","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-avoid-prompt-when-using-debug\/","title":{"rendered":"PowerTip: Avoid Prompt When Using &#8211;Debug"},"content":{"rendered":"<p><b style=\"font-size:12px\">Summary<\/b><span style=\"font-size:12px\">: Boe Prox shows how to avoid being prompted when using&nbsp;<\/span><b style=\"font-size:12px\">&ndash;Debug<\/b><span style=\"font-size:12px\">.<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>&nbsp;I love using&nbsp;<b>&ndash;Debug<\/b>&nbsp;in functions to figure out what is going on, but how can I avoid being prompted <br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;each time I run into&nbsp;<b>Write-Debug<\/b>&nbsp;in my code?<\/p>\n<p style=\"margin-left:30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>&nbsp;After you declare your parameters, check for&nbsp;<b>&ndash;Debug<\/b>, and set the&nbsp;<b>$DebugPreference<\/b>&nbsp;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;value to&nbsp;<b>&lsquo;Continue&rsquo;<\/b>&nbsp;instead of&nbsp;<b>&lsquo;Inquire&rsquo;<\/b>:<\/p>\n<p style=\"margin-left:120px\">If ($PSBoundParameters[&lsquo;Debug&rsquo;]) {<\/p>\n<p style=\"margin-left:120px\">&nbsp;&nbsp;&nbsp; $DebugPreference=&#039;Continue&#039;<\/p>\n<p style=\"margin-left:120px\">}<\/p>\n<p style=\"margin-left:30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\" alt=\" \" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Boe Prox shows how to avoid being prompted when using&nbsp;&ndash;Debug. &nbsp;I love using&nbsp;&ndash;Debug&nbsp;in functions to figure out what is going on, but how can I avoid being prompted &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;each time I run into&nbsp;Write-Debug&nbsp;in my code? &nbsp;After you declare your parameters, check for&nbsp;&ndash;Debug, and set the&nbsp;$DebugPreference&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[162,356,3,554,45],"class_list":["post-261","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-boe-prox","tag-powertip","tag-scripting-guy","tag-streams","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Boe Prox shows how to avoid being prompted when using&nbsp;&ndash;Debug. &nbsp;I love using&nbsp;&ndash;Debug&nbsp;in functions to figure out what is going on, but how can I avoid being prompted &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;each time I run into&nbsp;Write-Debug&nbsp;in my code? &nbsp;After you declare your parameters, check for&nbsp;&ndash;Debug, and set the&nbsp;$DebugPreference&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=261"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/261\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}