{"id":1962,"date":"2012-01-06T11:32:25","date_gmt":"2012-01-06T16:32:25","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=1962"},"modified":"2012-01-06T11:32:25","modified_gmt":"2012-01-06T16:32:25","slug":"friday-fun-whats-my-variable","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/","title":{"rendered":"Friday Fun What&#8217;s My Variable"},"content":{"rendered":"<p>I use scriptblocks quite a bit in my PowerShell work, often saved as variables. These are handy for commands you want to run again, but don't necessarily need to turn into permanent functions.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\n$freec={(get-wmiobject win32_logicaldisk -filter \"deviceid='c:'\" -property Freespace).FreeSpace\/1mb}<br \/>\n<\/code><\/p>\n<p>Now in PowerShell I can invoke the scriptblock.<\/p>\n<p><code><br \/>\nPS S:\\> &$freec<br \/>\n94079.72265625<br \/>\n<\/code><\/p>\n<p>Ok then. I have a number of these defined. I decided I wanted an easy way to identify them when I run Get-Variable. For example, if I remembered all the variable names I could just do this:<\/p>\n<p><code><br \/>\nPS S:\\> get-variable freec,dirt<\/p>\n<p>Name                           Value<br \/>\n----                           -----<br \/>\nfreec                          (gwmi win32_logicaldisk -filter \"deviceid='c:...<br \/>\ndirt                           Param([string]$Path=$env:temp) Get-ChildItem ...<br \/>\n<\/code><\/p>\n<p>But needless to say that's asking too much. When I first looked at this problem I went down the path of trying to parse values I saw with Get-Variable to identify potential script blocks. Then I realized this was a rookie mistake. PowerShell is all about the objects. Now a variable is also an object with a value property. This value could be a string, and integer or a pscredential. So my task then was to identify each value <em>type<\/em>.<\/p>\n<p>Every object in PowerShell has a built in method called GetType().<\/p>\n<p><code><br \/>\nPS S:\\> $s=get-service spooler<br \/>\nPS S:\\> $s.GetType()<\/p>\n<p>IsPublic IsSerial Name                                     BaseType<br \/>\n-------- -------- ----                                     --------<br \/>\nTrue     False    ServiceController                        System.ComponentM...<br \/>\n<\/code><\/p>\n<p>This is actually another object with a Name property.<\/p>\n<p><code><br \/>\nPS S:\\> $s.GetType().name<br \/>\nServiceController<br \/>\n<\/code><\/p>\n<p>Aha! Let's look at this with my variable.<\/p>\n<p><code><br \/>\nPS S:\\> (get-variable freec).value.GetType().Name<br \/>\nScriptBlock<br \/>\n<\/code><\/p>\n<p>This is a one-line shortcut that gets the Value property of the Freec variable and then runs the GetType() method followed by retrieving just the Name property. This is promising.  Here's one way I can use this:<\/p>\n<p><code lang=\"PowerShell\"><br \/>\nget-variable | Where {$_.value.GetType().Name -eq \"ScriptBlock\"}<br \/>\n<\/code><\/p>\n<p>As you can see there is still an issue with variables with no values.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-1-300x197.png\" alt=\"\" title=\"get-variabletype-1\" width=\"300\" height=\"197\" class=\"aligncenter size-medium wp-image-1963\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-1-300x197.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-1-1024x674.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-1.png 1157w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>I'll just add another condition to my Where expression.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\nget-variable | Where {$_.value -AND $_.value.GetType().Name -eq \"ScriptBlock\"}<br \/>\n<\/code><\/p>\n<p>Success!<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-2-300x116.png\" alt=\"\" title=\"get-variabletype-2\" width=\"300\" height=\"116\" class=\"aligncenter size-medium wp-image-1964\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-2-300x116.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-2-1024x398.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-2.png 1157w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>These are in fact all of the scriptblocks in my current session. But now I can take this a step further and look at my other variables and their type.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\nget-variable | select Name,@{Name=\"Type\";Expression={$_.value.GetType().Name}}<br \/>\n<\/code><\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-3-300x185.png\" alt=\"\" title=\"get-variabletype-3\" width=\"300\" height=\"185\" class=\"aligncenter size-medium wp-image-1965\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-3-300x185.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-3-1024x631.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-3.png 1157w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Or I might try grouping.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\nget-variable | select Name,@{Name=\"Type\";Expression={$_.value.GetType().Name}} | where {$_.type} | Group Type | Sort Count -Descending<br \/>\n<\/code><\/p>\n<p>I wanted to filter out empty values so I'm only keeping objects that have a defined type in my grouped output.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-4.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-4-300x185.png\" alt=\"\" title=\"get-variabletype-4\" width=\"300\" height=\"185\" class=\"aligncenter size-medium wp-image-1966\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-4-300x185.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-4-1024x631.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-4.png 1157w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The bottom line is never forget about the object!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I use scriptblocks quite a bit in my PowerShell work, often saved as variables. These are handy for commands you want to run again, but don&#8217;t necessarily need to turn into permanent functions. $freec={(get-wmiobject win32_logicaldisk -filter &#8220;deviceid=&#8217;c:'&#8221; -property Freespace).FreeSpace\/1mb} Now in PowerShell I can invoke the scriptblock. PS S:\\> &#038;$freec 94079.72265625 Ok then. I have&#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":[271,4],"tags":[230,258,144,534,352,261],"class_list":["post-1962","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell","tag-fridayfun","tag-get-variable","tag-objects","tag-powershell","tag-type","tag-variable"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun What&#039;s My Variable &#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\/powershell\/1962\/friday-fun-whats-my-variable\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun What&#039;s My Variable &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I use scriptblocks quite a bit in my PowerShell work, often saved as variables. These are handy for commands you want to run again, but don&#039;t necessarily need to turn into permanent functions. $freec={(get-wmiobject win32_logicaldisk -filter &quot;deviceid=&#039;c:&#039;&quot; -property Freespace).FreeSpace\/1mb} Now in PowerShell I can invoke the scriptblock. PS S:&gt; &amp;$freec 94079.72265625 Ok then. I have...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2012-01-06T16:32:25+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-1-300x197.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\\\/powershell\\\/1962\\\/friday-fun-whats-my-variable\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1962\\\/friday-fun-whats-my-variable\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun What&#8217;s My Variable\",\"datePublished\":\"2012-01-06T16:32:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1962\\\/friday-fun-whats-my-variable\\\/\"},\"wordCount\":324,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1962\\\/friday-fun-whats-my-variable\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/01\\\/get-variabletype-1-300x197.png\",\"keywords\":[\"FridayFun\",\"Get-variable\",\"objects\",\"PowerShell\",\"Type\",\"Variable\"],\"articleSection\":[\"Friday Fun\",\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1962\\\/friday-fun-whats-my-variable\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1962\\\/friday-fun-whats-my-variable\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1962\\\/friday-fun-whats-my-variable\\\/\",\"name\":\"Friday Fun What's My Variable &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1962\\\/friday-fun-whats-my-variable\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1962\\\/friday-fun-whats-my-variable\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/01\\\/get-variabletype-1-300x197.png\",\"datePublished\":\"2012-01-06T16:32:25+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1962\\\/friday-fun-whats-my-variable\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1962\\\/friday-fun-whats-my-variable\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1962\\\/friday-fun-whats-my-variable\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/01\\\/get-variabletype-1.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/01\\\/get-variabletype-1.png\",\"width\":\"1157\",\"height\":\"762\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1962\\\/friday-fun-whats-my-variable\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun What&#8217;s My Variable\"}]},{\"@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":"Friday Fun What's My Variable &#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\/powershell\/1962\/friday-fun-whats-my-variable\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun What's My Variable &#8226; The Lonely Administrator","og_description":"I use scriptblocks quite a bit in my PowerShell work, often saved as variables. These are handy for commands you want to run again, but don't necessarily need to turn into permanent functions. $freec={(get-wmiobject win32_logicaldisk -filter \"deviceid='c:'\" -property Freespace).FreeSpace\/1mb} Now in PowerShell I can invoke the scriptblock. PS S:> &$freec 94079.72265625 Ok then. I have...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/","og_site_name":"The Lonely Administrator","article_published_time":"2012-01-06T16:32:25+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-1-300x197.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\/powershell\/1962\/friday-fun-whats-my-variable\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun What&#8217;s My Variable","datePublished":"2012-01-06T16:32:25+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/"},"wordCount":324,"commentCount":1,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-1-300x197.png","keywords":["FridayFun","Get-variable","objects","PowerShell","Type","Variable"],"articleSection":["Friday Fun","PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/","name":"Friday Fun What's My Variable &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-1-300x197.png","datePublished":"2012-01-06T16:32:25+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-1.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-1.png","width":"1157","height":"762"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"Friday Fun What&#8217;s My Variable"}]},{"@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":995,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/995\/friday-fun-the-kitchen-sink-prompt\/","url_meta":{"origin":1962,"position":0},"title":"Friday Fun &#8211; The Kitchen Sink Prompt","author":"Jeffery Hicks","date":"October 29, 2010","format":false,"excerpt":"On my last Friday Fun post on PowerShell prompts, I got a terrific comment from Bart Vandyck about his prompt which has just about everything you would want. I too have a \"kitchen sink\" prompt, that is to say, one with the proverbial \"everything but the kitchen sink\". Or you\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\/10\/everything-console-1024x798.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/10\/everything-console-1024x798.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/10\/everything-console-1024x798.png?resize=525%2C300 1.5x"},"classes":[]},{"id":1653,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1653\/the-powershell-day-care-building-scriptblocks\/","url_meta":{"origin":1962,"position":1},"title":"The PowerShell Day Care: Building ScriptBlocks","author":"Jeffery Hicks","date":"September 22, 2011","format":false,"excerpt":"Good morning kids and welcome to the PowerShell Day Care center. We offer a creative and nurturing environment for PowerShell professionals of all ages. Later there might even be juice and cookies. But first let's get out our blocks, our scriptblocks, and start building. I've written a number of posts\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":2555,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2555\/friday-fun-a-gridview-drive-report\/","url_meta":{"origin":1962,"position":2},"title":"Friday Fun: A GridView Drive Report","author":"Jeffery Hicks","date":"November 2, 2012","format":false,"excerpt":"I've been experimenting with different techniques to work with PowerShell in graphical ways, but without resorting to complex solutions such as WinForms or ShowUI. For today's Friday Fun I have a little script that presents a drive usage report using WMI and Out-GridView. As always, my goal with these articles\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\/2012\/11\/gridview-drivereport1-300x159.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":654,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/654\/new-wmi-object\/","url_meta":{"origin":1962,"position":3},"title":"New WMI Object","author":"Jeffery Hicks","date":"May 17, 2010","format":false,"excerpt":"I have one more variation on my recent theme of working with WMI objects. I wanted to come up with something flexible and re-usable where you could specify a WMI class and some properties and get a custom object with all the classes combined. My solution is a function called\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":9074,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9074\/the-value-of-objects\/","url_meta":{"origin":1962,"position":4},"title":"The Value of Objects","author":"Jeffery Hicks","date":"July 5, 2022","format":false,"excerpt":"This is a reprint of an article published earlier this year in my premium PowerShell newsletter, Behind the PowerShell Pipeline. This is a sample of what my subscribers get 6-8 times a month. I expect I will write several articles about PowerShell and its relationship with objects. I know that\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\/2022\/07\/getting-drive-usage.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/07\/getting-drive-usage.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/07\/getting-drive-usage.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":889,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/889\/get-some-style\/","url_meta":{"origin":1962,"position":5},"title":"Get Some Style","author":"Jeffery Hicks","date":"August 31, 2010","format":false,"excerpt":"Windows PowerShell has many ways to present and store information. You can display it to the screen, write it to a file, send it to a printer, create an CSV or XML file or even a pretty HTML report. The ConvertTo-HTML cmdlet underwent a significant facelift for v2.0 and is\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\/1962","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=1962"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1962\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}