{"id":1423,"date":"2011-05-11T08:14:36","date_gmt":"2011-05-11T12:14:36","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=1423"},"modified":"2011-05-11T08:14:36","modified_gmt":"2011-05-11T12:14:36","slug":"warning-signs","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/","title":{"rendered":"Warning Signs"},"content":{"rendered":"<p>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 works and one doesn't. But I worked out a hack for the obstinate one.<!--more--><\/p>\n<p>The common parameters are supported on all cmdlets and any PowerShell script or function using cmdletbinding. That's the thing you see at the beginning of most scripts:<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\n[cmdletBinding()]<br \/>\n[\/cc]<\/p>\n<p>This is what allows you to use commands like Write-Verbose in your function that will only execute when you pass -Verbose when running the function. Actually, the command always runs it's just that the verbose message doesn't get written unless you use -Verbose. You can do the same thing with Write-Warning.  <\/p>\n<p>A related common parameter is -WarningVariable (and its companion -ErrorVariable). When you use these parameters to call your function, warnings and errors should be written to these variables.<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\nPS C:\\> MyFunction -name \"Jeff\" -warningvariable wv -errorvariable ev -verbose<br \/>\n[\/cc]<\/p>\n<p>Any Write-Verbose messages will be displayed, warnings will be stored in $wv and errors in $ev. The error variable works as designed, warnings do not. This has been reported as a bug on the Connect site. Although if I had checked there first, I might not have figured out a work around.<\/p>\n<p>It turns out this will still work, but you have to explicitly use the -WarningVariable parameter with any Write-Warning expressions in your script or function. The value will be the WarningVariable value from $PSBoundParameters. Use an expression like this:<\/p>\n<p>[cc lang=\"Powershell\"]<br \/>\nWrite-Warning \"Foo Warning $(Get-Date)\" -WarningVariable $PSBoundParameters.WarningVariable<br \/>\n[\/cc]<\/p>\n<p>The second part to the hack is that when you invoke the function and use the -WarningVariable, you need to specify the variable name with the + sign. This tells PowerShell to append to the variable. Now I can run my command and save warnings and errors to their respective variables.<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\nPS C:\\> myfunction -WarningVariable +wv -ErrorVariable ev -name foober -verbose<br \/>\n[\/cc]<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/warningvariable.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/warningvariable-300x184.png\" alt=\"\" title=\"warningvariable\" width=\"300\" height=\"184\" class=\"aligncenter size-medium wp-image-1424\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/warningvariable-300x184.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/warningvariable-1024x629.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/warningvariable.png 1357w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Here's the code:<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\nFunction MyFunction {<br \/>\n[cmdletbinding()]<\/p>\n<p>Param(<br \/>\n[string]$Name=\"Chaokoh\")<\/p>\n<p>write-verbose \"Running the function\"<br \/>\n#$PSBoundParameters<\/p>\n<p>Get-Date<br \/>\nwrite $name<\/p>\n<p>Write-Warning \"Foo Warning $(Get-Date)\" -WarningVariable $PSBoundParameters.WarningVariable<\/p>\n<p>Try {<br \/>\n    Write-Host \"I'm trying...\" -Foreground green<br \/>\n    Write-Error \"I am problem $(Get-Random) $(Get-Date)\" -ErrorAction Stop<br \/>\n}<br \/>\nCatch {<br \/>\n    Write-Host \"Exception caught\" -ForegroundColor red<br \/>\n    Write-Warning \"oops $(Get-date)\" -WarningVariable $PSBoundParameters.WarningVariable<\/p>\n<p>}<\/p>\n<p>Write-Warning \"Foo Warning $(Get-Date)\" -WarningVariable $PSBoundParameters.WarningVariable<\/p>\n<p>write-error \"I am another error\" <\/p>\n<p>Get-date<br \/>\n}<br \/>\n[\/cc]<\/p>\n<p>Or if you would like to try this out yourself, you can download <a href='http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/Myfunction.txt' target=\"_blank\">Myfunction.ps1<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 works and one doesn&#8217;t. But&#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":[224,534,261,285],"class_list":["post-1423","post","type-post","status-publish","format-standard","hentry","category-powershell-v2-0","category-scripting","tag-function","tag-powershell","tag-variable","tag-write-warning"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Warning Signs &#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\/1423\/warning-signs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Warning Signs &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"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 works and one doesn&#039;t. But...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2011-05-11T12:14:36+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/warningvariable-300x184.png\" \/>\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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1423\\\/warning-signs\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1423\\\/warning-signs\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Warning Signs\",\"datePublished\":\"2011-05-11T12:14:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1423\\\/warning-signs\\\/\"},\"wordCount\":446,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1423\\\/warning-signs\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/warningvariable-300x184.png\",\"keywords\":[\"Function\",\"PowerShell\",\"Variable\",\"Write-Warning\"],\"articleSection\":[\"PowerShell v2.0\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1423\\\/warning-signs\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1423\\\/warning-signs\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1423\\\/warning-signs\\\/\",\"name\":\"Warning Signs &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1423\\\/warning-signs\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1423\\\/warning-signs\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/warningvariable-300x184.png\",\"datePublished\":\"2011-05-11T12:14:36+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1423\\\/warning-signs\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1423\\\/warning-signs\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1423\\\/warning-signs\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/warningvariable.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/warningvariable.png\",\"width\":\"1357\",\"height\":\"834\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1423\\\/warning-signs\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell v2.0\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-v2-0\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Warning Signs\"}]},{\"@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":"Warning Signs &#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\/1423\/warning-signs\/","og_locale":"en_US","og_type":"article","og_title":"Warning Signs &#8226; The Lonely Administrator","og_description":"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 works and one doesn't. But...","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/","og_site_name":"The Lonely Administrator","article_published_time":"2011-05-11T12:14:36+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/warningvariable-300x184.png","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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Warning Signs","datePublished":"2011-05-11T12:14:36+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/"},"wordCount":446,"commentCount":7,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/warningvariable-300x184.png","keywords":["Function","PowerShell","Variable","Write-Warning"],"articleSection":["PowerShell v2.0","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/","name":"Warning Signs &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/warningvariable-300x184.png","datePublished":"2011-05-11T12:14:36+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/warningvariable.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/warningvariable.png","width":"1357","height":"834"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell v2.0","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},{"@type":"ListItem","position":2,"name":"Warning Signs"}]},{"@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":1173,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1173\/get-my-variables\/","url_meta":{"origin":1423,"position":0},"title":"Get My Variables","author":"Jeffery Hicks","date":"March 2, 2011","format":false,"excerpt":"As you might imagine I write a lot of PowerShell scripts and examples. Often my PowerShell Window is open for days at a time. One challenge I have always has is trying to remember what variables I have defined. If I knew the name I'd simply use Get-Variable. What I\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1011,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1011\/friday-fun-quote-of-the-day\/","url_meta":{"origin":1423,"position":1},"title":"Friday Fun Quote of the Day","author":"Jeffery Hicks","date":"November 5, 2010","format":false,"excerpt":"For this week's Friday Fun post, I have another idea on how to brighten your PowerShell console. The concept of a message of the day or quote of the day in computing goes way back to the dark ages (ie before PowerShell). I thought it might be fun to see\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\/2010\/11\/qotd.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/11\/qotd.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/11\/qotd.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/11\/qotd.png?resize=700%2C400 2x"},"classes":[]},{"id":933,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/933\/powershell-ise-new-function\/","url_meta":{"origin":1423,"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":1589,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1589\/verbose-or-debug\/","url_meta":{"origin":1423,"position":3},"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":1025,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1025\/out-compressedfile\/","url_meta":{"origin":1423,"position":4},"title":"Out-CompressedFile","author":"Jeffery Hicks","date":"December 6, 2010","format":false,"excerpt":"I'm not sure where this idea came from, but I thought it might be nice to redirect output to a compressed text file. I know disk space is cheap these days but perhaps you're running PowerShell 2.0 on an older platform and you want to save output from a command\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/12\/out-compressedfile-1024x619.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/12\/out-compressedfile-1024x619.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/12\/out-compressedfile-1024x619.png?resize=525%2C300 1.5x"},"classes":[]},{"id":4319,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4319\/powershell-blogging-week-supporting-whatif-and-confirm\/","url_meta":{"origin":1423,"position":5},"title":"PowerShell Blogging Week: Supporting WhatIf and Confirm","author":"Jeffery Hicks","date":"April 2, 2015","format":false,"excerpt":"We hope you are enjoying this experiment in community blogging. In today's contribution I want to demonstrate how you can add support for WhatIf and Confirm to your advanced PowerShell functions. It is actually quite easy, especially if your function is simply calling other PowerShell commands that already support \u2013Whatif\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1423","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=1423"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1423\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}