{"id":628,"date":"2010-04-28T10:10:59","date_gmt":"2010-04-28T15:10:59","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/2010\/04\/verbose-variations\/"},"modified":"2013-07-02T08:14:45","modified_gmt":"2013-07-02T12:14:45","slug":"verbose-variations","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/","title":{"rendered":"Verbose Variations"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/talkbubble.gif\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px\" title=\"talkbubble\" border=\"0\" alt=\"talkbubble\" align=\"left\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/talkbubble_thumb.gif\" width=\"99\" height=\"104\" \/><\/a> While I\u2019ve been judging entries in the 2010 Scripting Games, I\u2019ve noticed a few things that I thought I would comment on here. In longer and complicated scripts, I\u2019ve always suggested script developers provide some sort of feedback about what the script is doing.&#160; Typically this is done with <a title=\"Get online help for this cmdlet\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113426\" target=\"_blank\">Write-Host<\/a>, but there are several ways you can approach this. Let me discuss a few variations.<\/p>\n<p> <!--more-->  <\/p>\n<p>The first approach is to simply use Write-Host throughout the script to provide feedback or even debugging information. I always suggest using a different color to distinguish it from your script\u2019s pipelined output. Here\u2019s an example.<\/p>\n<p>&#160;<\/p>\n<pre class=\"PowerShellColorizedScript\"><span style=\"color: #00008b\">Param<\/span> <span style=\"color: #000000\">(<\/span><span style=\"color: #008080\">[string]<\/span><span style=\"color: #ff4500\">$computername<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$env:computername<\/span><span style=\"color: #000000\">)<\/span>            \n            \n<span style=\"color: #0000ff\">write-host<\/span> <span style=\"color: #8b0000\">&quot;Starting script&quot;<\/span> <span style=\"color: #000080\">-ForegroundColor<\/span> <span style=\"color: #8a2be2\">Cyan<\/span>            \n<span style=\"color: #0000ff\">write-host<\/span> <span style=\"color: #8b0000\">&quot;Connecting to $computername&quot;<\/span> <span style=\"color: #000080\">-ForegroundColor<\/span> <span style=\"color: #8a2be2\">Cyan<\/span>            \n            \n<span style=\"color: #0000ff\">Get-WmiObject<\/span> <span style=\"color: #000080\">-ComputerName<\/span> <span style=\"color: #ff4500\">$computername<\/span> <span style=\"color: #000080\">-Class<\/span> <span style=\"color: #8a2be2\">Win32_BIOS<\/span>            \n            \n<span style=\"color: #0000ff\">write-host<\/span> <span style=\"color: #8b0000\">&quot;Ending Script&quot;<\/span> <span style=\"color: #000080\">-ForegroundColor<\/span> <span style=\"color: #8a2be2\">Cyan<\/span><\/pre>\n<\/p>\n<p>For short scripts and situations where you always want the feedback, there\u2019s nothing wrong with this approach. One variation I\u2019ve seen, and have used myself in the past, is to make these statements contingent.<\/p>\n<\/p>\n<pre class=\"PowerShellColorizedScript\"><span style=\"color: #00008b\">Param<\/span> <span style=\"color: #000000\">(<\/span><span style=\"color: #008080\">[string]<\/span><span style=\"color: #ff4500\">$computername<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$env:computername<\/span><span style=\"color: #a9a9a9\">,<\/span>            \n       <span style=\"color: #008080\">[switch]<\/span><span style=\"color: #ff4500\">$verbose<\/span>            \n<span style=\"color: #000000\">)<\/span>            \n            \n<span style=\"color: #00008b\">if<\/span> <span style=\"color: #000000\">(<\/span><span style=\"color: #ff4500\">$verbose<\/span><span style=\"color: #000000\">)<\/span> <span style=\"color: #000000\">{<\/span><span style=\"color: #0000ff\">write-host<\/span> <span style=\"color: #8b0000\">&quot;Starting script&quot;<\/span> <span style=\"color: #000080\">-ForegroundColor<\/span> <span style=\"color: #8a2be2\">Cyan<\/span><span style=\"color: #000000\">}<\/span>            \n<span style=\"color: #00008b\">if<\/span> <span style=\"color: #000000\">(<\/span><span style=\"color: #ff4500\">$verbose<\/span><span style=\"color: #000000\">)<\/span> <span style=\"color: #000000\">{<\/span><span style=\"color: #0000ff\">write-host<\/span> <span style=\"color: #8b0000\">&quot;Connecting to $computername&quot;<\/span> `<br \/><span style=\"color: #000080\">-ForegroundColor<\/span> <span style=\"color: #8a2be2\">Cyan<\/span><span style=\"color: #000000\">}<\/span>            \n            \n<span style=\"color: #0000ff\">Get-WmiObject<\/span> <span style=\"color: #000080\">-ComputerName<\/span> <span style=\"color: #ff4500\">$computername<\/span> <span style=\"color: #000080\">-Class<\/span> <span style=\"color: #8a2be2\">Win32_BIOS<\/span>            \n            \n<span style=\"color: #00008b\">if<\/span> <span style=\"color: #000000\">(<\/span><span style=\"color: #ff4500\">$verbose<\/span><span style=\"color: #000000\">)<\/span> <span style=\"color: #000000\">{<\/span><span style=\"color: #0000ff\">write-host<\/span> <span style=\"color: #8b0000\">&quot;Ending Script&quot;<\/span> <span style=\"color: #000080\">-ForegroundColor<\/span> <span style=\"color: #8a2be2\">Cyan<\/span><span style=\"color: #000000\">}<\/span><\/pre>\n<\/p>\n<p>Now, the Write-Host lines will only execute if I\u2019ve included \u2013Verbose as a parameter. There\u2019s nothing technically wrong with this approach. Although for my tastes it seems a bit heavy handed.&#160; A better variation, in my opinion, is to use <a title=\"get online help for this cmdlet\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113429\" target=\"_blank\">Write-Verbose<\/a>.&#160; This cmdlet will write a message to the verbose pipeline which by default is yellow text on a black background. Thus, the output doesn\u2019t interfere with the script\u2019s pipelined output and it is easily distinguished. You could simple keep the current version of my script sample and replace Write-Host with Write-Verbose, but there are two issues.<\/p>\n<p>First, it is still clunky with all the If statements. Plus, by default the verbose pipeline is turned off. You need to set the $VerbosePreference to Continue to enable it. Here\u2019s an even better way.<\/p>\n<\/p>\n<pre class=\"PowerShellColorizedScript\"><span style=\"color: #00008b\">Param<\/span> <span style=\"color: #000000\">(<\/span><span style=\"color: #008080\">[string]<\/span><span style=\"color: #ff4500\">$computername<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$env:computername<\/span><span style=\"color: #a9a9a9\">,<\/span>            \n       <span style=\"color: #008080\">[switch]<\/span><span style=\"color: #ff4500\">$verbose<\/span>            \n<span style=\"color: #000000\">)<\/span>            \n            \n<span style=\"color: #00008b\">if<\/span> <span style=\"color: #000000\">(<\/span><span style=\"color: #ff4500\">$verbose<\/span><span style=\"color: #000000\">)<\/span> <span style=\"color: #000000\">{<\/span> <span style=\"color: #ff4500\">$verbosePreference<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #8b0000\">&quot;Continue&quot;<\/span><span style=\"color: #000000\">}<\/span>            \n            \n<span style=\"color: #0000ff\">write-verbose<\/span> <span style=\"color: #8b0000\">&quot;Starting script&quot;<\/span>            \n<span style=\"color: #0000ff\">write-verbose<\/span> <span style=\"color: #8b0000\">&quot;Connecting to $computername&quot;<\/span>            \n            \n<span style=\"color: #0000ff\">Get-WmiObject<\/span> <span style=\"color: #000080\">-ComputerName<\/span> <span style=\"color: #ff4500\">$computername<\/span> <span style=\"color: #000080\">-Class<\/span> <span style=\"color: #8a2be2\">Win32_BIOS<\/span>            \n            \n<span style=\"color: #0000ff\">write-verbose<\/span> <span style=\"color: #8b0000\">&quot;Ending Script&quot;<\/span><\/pre>\n<\/p>\n<p>But wait\u2026there\u2019s more. PowerShell 2.0 let\u2019s us write advanced functions and scripts that act like cmdlets which support the common parameters, including \u2013verbose. All that is required is to tell PowerShell to treat the script or function as a cmdlet.<\/p>\n<\/p>\n<pre class=\"PowerShellColorizedScript\"><span style=\"color: #006400\">#requires -Version 2.0<\/span>            \n            \n<span style=\"color: #a9a9a9\">[<\/span><span style=\"color: #add8e6\">CmdletBinding<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #a9a9a9\">]<\/span>            \n            \n<span style=\"color: #00008b\">Param<\/span> <span style=\"color: #000000\">(<\/span><span style=\"color: #008080\">[string]<\/span><span style=\"color: #ff4500\">$computername<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$env:computername<\/span><span style=\"color: #000000\">)<\/span>            \n            \n<span style=\"color: #0000ff\">write-verbose<\/span> <span style=\"color: #8b0000\">&quot;Starting script&quot;<\/span>            \n<span style=\"color: #0000ff\">write-verbose<\/span> <span style=\"color: #8b0000\">&quot;Connecting to $computername&quot;<\/span>            \n            \n<span style=\"color: #0000ff\">Get-WmiObject<\/span> <span style=\"color: #000080\">-ComputerName<\/span> <span style=\"color: #ff4500\">$computername<\/span> <span style=\"color: #000080\">-Class<\/span> <span style=\"color: #8a2be2\">Win32_BIOS<\/span>            \n            \n<span style=\"color: #0000ff\">write-verbose<\/span> <span style=\"color: #8b0000\">&quot;Ending Script&quot;<\/span><\/pre>\n<\/p>\n<p>The [CmdletBinding()] directive must be before the Param statement. When I run the script and use \u2013verbose, PowerShell will enable the verbose pipeline and I\u2019ll see the output from all the Write-Verbose commands.&#160; No parameter, no verbose output. For that reason, I like including verbose output from the very beginning of script development. It provides useful feedback about what the code is doing and provides debug-type information about variables and the like. Plus the statements can serve double-duty as inline documentation.<\/p>\n<p>Whether you use Write-Host or Write-Verbose ultimately is a matter of choice and scripting requirements and there\u2019s no reason you can\u2019t use both. You might always want information displayed to the person running the script, in which case Write-Host makes perfect sense. You can then use Write-Verbose for more detailed information. Including these commands from the beginning, makes troubleshooting scripts much, much easier.<\/p>\n<p>Of course, if you really want to provide feedback, take some time to work with <a title=\"Get online help for this cmdlet\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113428\" target=\"_blank\">Write-Progress<\/a>. But that\u2019s a topic for another day.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While I\u2019ve been judging entries in the 2010 Scripting Games, I\u2019ve noticed a few things that I thought I would comment on here. In longer and complicated scripts, I\u2019ve always suggested script developers provide some sort of feedback about what the script is doing.&#160; Typically this is done with Write-Host, but there are several ways&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[75,8],"tags":[188,534,101,187],"class_list":["post-628","post","type-post","status-publish","format-standard","hentry","category-powershell-v2-0","category-scripting","tag-cmdletbinding","tag-powershell","tag-write-host","tag-write-verbose"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Verbose Variations &#8226; The Lonely Administrator<\/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:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Verbose Variations &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"While I\u2019ve been judging entries in the 2010 Scripting Games, I\u2019ve noticed a few things that I thought I would comment on here. In longer and complicated scripts, I\u2019ve always suggested script developers provide some sort of feedback about what the script is doing.&#160; Typically this is done with Write-Host, but there are several ways...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2010-04-28T15:10:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-07-02T12:14:45+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/talkbubble_thumb.gif\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\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:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/628\\\/verbose-variations\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/628\\\/verbose-variations\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Verbose Variations\",\"datePublished\":\"2010-04-28T15:10:59+00:00\",\"dateModified\":\"2013-07-02T12:14:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/628\\\/verbose-variations\\\/\"},\"wordCount\":493,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/628\\\/verbose-variations\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2010\\\/04\\\/talkbubble_thumb.gif\",\"keywords\":[\"CmdletBinding\",\"PowerShell\",\"Write-Host\",\"Write-Verbose\"],\"articleSection\":[\"PowerShell v2.0\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/628\\\/verbose-variations\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/628\\\/verbose-variations\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/628\\\/verbose-variations\\\/\",\"name\":\"Verbose Variations &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/628\\\/verbose-variations\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/628\\\/verbose-variations\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2010\\\/04\\\/talkbubble_thumb.gif\",\"datePublished\":\"2010-04-28T15:10:59+00:00\",\"dateModified\":\"2013-07-02T12:14:45+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/628\\\/verbose-variations\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/628\\\/verbose-variations\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/628\\\/verbose-variations\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2010\\\/04\\\/talkbubble_thumb.gif\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2010\\\/04\\\/talkbubble_thumb.gif\",\"width\":\"99\",\"height\":\"104\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/628\\\/verbose-variations\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell v2.0\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-v2-0\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Verbose Variations\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Verbose Variations &#8226; The Lonely Administrator","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:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/","og_locale":"en_US","og_type":"article","og_title":"Verbose Variations &#8226; The Lonely Administrator","og_description":"While I\u2019ve been judging entries in the 2010 Scripting Games, I\u2019ve noticed a few things that I thought I would comment on here. In longer and complicated scripts, I\u2019ve always suggested script developers provide some sort of feedback about what the script is doing.&#160; Typically this is done with Write-Host, but there are several ways...","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/","og_site_name":"The Lonely Administrator","article_published_time":"2010-04-28T15:10:59+00:00","article_modified_time":"2013-07-02T12:14:45+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/talkbubble_thumb.gif","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Verbose Variations","datePublished":"2010-04-28T15:10:59+00:00","dateModified":"2013-07-02T12:14:45+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/"},"wordCount":493,"commentCount":4,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/talkbubble_thumb.gif","keywords":["CmdletBinding","PowerShell","Write-Host","Write-Verbose"],"articleSection":["PowerShell v2.0","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/","name":"Verbose Variations &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/talkbubble_thumb.gif","datePublished":"2010-04-28T15:10:59+00:00","dateModified":"2013-07-02T12:14:45+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/talkbubble_thumb.gif","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/talkbubble_thumb.gif","width":"99","height":"104"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/628\/verbose-variations\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell v2.0","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},{"@type":"ListItem","position":2,"name":"Verbose Variations"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1597,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1597\/friday-fun-export-transcript-to-script\/","url_meta":{"origin":628,"position":0},"title":"Friday Fun Export Transcript to Script","author":"Jeffery Hicks","date":"August 12, 2011","format":false,"excerpt":"Over the years I've posted variations on this technique and discuss it often in my training classes. The idea is to take your PowerShell transcript and transform it into a PowerShell script. Remember that there is very little difference between running commands in the shell and in a script. Thus,\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2033,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2033\/friday-fun-get-content-words\/","url_meta":{"origin":628,"position":1},"title":"Friday Fun Get Content Words","author":"Jeffery Hicks","date":"January 27, 2012","format":false,"excerpt":"Recently I was tracking down a bug in script for a client. The problem turned out to be a simple typo. I could have easily avoided that by using Set-StrictMode, which I do now, but that's not what this is about. What I realized I wanted was a way to\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-contentwords-300x228.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":933,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/933\/powershell-ise-new-function\/","url_meta":{"origin":628,"position":2},"title":"PowerShell ISE New Function","author":"Jeffery Hicks","date":"September 16, 2010","format":false,"excerpt":"Yesterday I showed how to add a menu choice to the PowerShell ISE to insert the current date and time. Today I have something even better. At least it's something I've needed for awhile. I write a lot of advanced functions in PowerShell. I'm often cutting and pasting from previous\u2026","rel":"","context":"In &quot;PowerShell ISE&quot;","block_context":{"text":"PowerShell ISE","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/09\/ise-addons.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1423,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/","url_meta":{"origin":628,"position":3},"title":"Warning Signs","author":"Jeffery Hicks","date":"May 11, 2011","format":false,"excerpt":"I was working on a project with an advanced PowerShell function. One of the goals was to take advantage of the common parameters like -ErrorVariable and -WarningVariable so that when you run the function you can save errors and warnings and work with them later. Turns out one of these\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/warningvariable-300x184.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1589,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1589\/verbose-or-debug\/","url_meta":{"origin":628,"position":4},"title":"Verbose or Debug?","author":"Jeffery Hicks","date":"August 8, 2011","format":false,"excerpt":"This morning there was some discussion on Twitter about when to use Write-Verbose and when to use Write-Debug. They both can provide additional information about what your script or function is doing, although you have to write the code. Typically, I use Write-Verbose to provide trace and flow messages. When\u2026","rel":"","context":"In &quot;Best Practices&quot;","block_context":{"text":"Best Practices","link":"https:\/\/jdhitsolutions.com\/blog\/category\/best-practices\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/08\/demo-write-verbose-300x110.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":5789,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5789\/who_is_running\/","url_meta":{"origin":628,"position":5},"title":"Who is Running Your PowerShell Script?","author":"Jeffery Hicks","date":"November 21, 2017","format":false,"excerpt":"I've often talked about the benefit of including Verbose output in your PowerShell scripts and functions from the very beginning. This is especially helpful when someone else is running your command but encounters a problem. You can have them start a transcript, run your command with \u2013Verbose, close the transcript\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb-17.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb-17.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb-17.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb-17.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=628"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/628\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}