{"id":2752,"date":"2013-01-24T09:54:16","date_gmt":"2013-01-24T14:54:16","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=2752"},"modified":"2013-01-24T09:54:16","modified_gmt":"2013-01-24T14:54:16","slug":"rename-hashtable-key-revised","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/","title":{"rendered":"Rename Hashtable Key Revised"},"content":{"rendered":"<p>Last week I posted an advanced PowerShell function to <a href=\"http:\/\/jdhitsolutions.com\/blog\/2013\/01\/rename-hashtable-key\/\" title=\"read the original post\" target=\"_blank\">rename a hashtable key<\/a>. As usual, the more I worked with it the more I realized it was missing something - namely the ability the take a pipelined object. My original version assumed you had saved the hashtable to a variable. But as I was working with <a href=\"http:\/\/jdhitsolutions.com\/blog\/2013\/01\/convert-powershell-object-to-hashtable-revised\/\" title=\"read about converting an object to a hashtable\" target=\"_blank\">ConvertTo-Hashtable<\/a> I realized the shortcoming. The solution was to modify Rename-Hashtable so that it could accept a hashtable as a piped value. <\/p>\n<p>I won't go through the function again. You can read the original post to learn more about how it works. Let's look at what changed. Because I wanted to retain the option to also specify a variable name, I created two parameters sets. One for the piped object and one for the variable name.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\n[cmdletbinding(SupportsShouldProcess=$True,DefaultParameterSetName=\"Pipeline\")]<\/p>\n<p>Param(<br \/>\n[parameter(Position=0,Mandatory=$True,<br \/>\nHelpMessage=\"Enter the name of your hash table variable without the `$\",<br \/>\nParameterSetName=\"Name\")]<br \/>\n[ValidateNotNullorEmpty()]<br \/>\n[string]$Name,<br \/>\n[parameter(Position=0,Mandatory=$True,<br \/>\nValueFromPipeline=$True,ParameterSetName=\"Pipeline\")]<br \/>\n[ValidateNotNullorEmpty()]<br \/>\n[object]$InputObject,<br \/>\n[parameter(position=1,Mandatory=$True,<br \/>\nHelpMessage=\"Enter the existing key name you want to rename\")]<br \/>\n[ValidateNotNullorEmpty()]<br \/>\n[string]$Key,<br \/>\n[parameter(position=2,Mandatory=$True,<br \/>\nHelpMessage=\"Enter the NEW key name\")]<br \/>\n[ValidateNotNullorEmpty()]<br \/>\n[string]$NewKey,<br \/>\n[switch]$Passthru,<br \/>\n[ValidateSet(\"Global\",\"Local\",\"Script\",\"Private\",0,1,2,3)]<br \/>\n[ValidateNotNullOrEmpty()]<br \/>\n[string]$Scope=\"Global\"<br \/>\n)<br \/>\n<\/code><\/p>\n<p>I defined parameter sets called Pipeline and Name and made the former the default in the cmdletbinding attribute. Because the remaining parameters would be in both parameter sets I didn't specify one. When looking at the function's help you can see the result.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets-1024x319.png\" alt=\"rename-hashtable-paramsets\" width=\"625\" height=\"194\" class=\"aligncenter size-large wp-image-2753\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets-1024x319.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets-300x93.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets-624x194.png 624w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets.png 1145w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p>Because I'm taking input from the pipeline, I needed to add a Process scriptblock. Within the scriptblock, if an object has been piped in, I turn on the passthru variable and create a temporary copy of the piped in hashtable.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\nProcess {<br \/>\n    #validate Key and NewKey are not the same<br \/>\n    if ($key -eq $NewKey) {<br \/>\n     Write-Warning \"The values you specified for -Key and -NewKey appear to be the same. Names are NOT case-sensitive\"<br \/>\n     Return<br \/>\n    }<\/p>\n<p>    Try {<br \/>\n        #validate variable is a hash table<br \/>\n        if ($InputObject) {<br \/>\n            $name=\"tmpInputHash\"<br \/>\n            Set-Variable -Name $name -Scope $scope -value $InputObject<br \/>\n            $Passthru=$True<br \/>\n        }<br \/>\n...<br \/>\n<\/code><\/p>\n<p>The rest of the code worked just fine and there was no reason to change it. All I needed to do was transform the -Inputobject value into the -Name value since I already had code that used $Name. Sometimes you need separate code blocks but in this case I didn't. Once the transformation is complete, the rest of the function runs as originally designed. With this version I can now run commands like this:<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS C:\\> $h = get-service spooler -computer Serenity | convertto-hashtable -NoEmpty -Exclude CanStop,CanPauseAndcontinue | rename-hashtable -key machinename -new computername<br \/>\nPS C:\\> $h<\/p>\n<p>Name                           Value<br \/>\n----                           -----<br \/>\ncomputername                   Serenity<br \/>\nName                           spooler<br \/>\nServiceName                    spooler<br \/>\nRequiredServices               {RPCSS, http}<br \/>\nDependentServices              {Fax}<br \/>\nServiceType                    Win32OwnProcess, InteractiveProcess<br \/>\nStatus                         Running<br \/>\nServicesDependedOn             {RPCSS, http}<br \/>\nServiceHandle                  SafeServiceHandle<br \/>\nDisplayName                    Print Spooler<br \/>\n<\/code><\/p>\n<p>Download <a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/Rename-Hashtable2.txt\" target=\"_blank\">Rename-Hashtable2<\/a> and give it a go.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week I posted an advanced PowerShell function to rename a hashtable key. As usual, the more I worked with it the more I realized it was missing something &#8211; namely the ability the take a pipelined object. My original version assumed you had saved the hashtable to a variable. But as I was working&#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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[199,307,98,534,540],"class_list":["post-2752","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-hashtable","tag-parameter","tag-pipeline","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Rename Hashtable Key Revised &#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\/2752\/rename-hashtable-key-revised\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Rename Hashtable Key Revised &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Last week I posted an advanced PowerShell function to rename a hashtable key. As usual, the more I worked with it the more I realized it was missing something - namely the ability the take a pipelined object. My original version assumed you had saved the hashtable to a variable. But as I was working...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2013-01-24T14:54:16+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets-1024x319.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\\\/2752\\\/rename-hashtable-key-revised\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2752\\\/rename-hashtable-key-revised\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Rename Hashtable Key Revised\",\"datePublished\":\"2013-01-24T14:54:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2752\\\/rename-hashtable-key-revised\\\/\"},\"wordCount\":306,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2752\\\/rename-hashtable-key-revised\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/01\\\/rename-hashtable-paramsets-1024x319.png\",\"keywords\":[\"hashtable\",\"parameter\",\"Pipeline\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2752\\\/rename-hashtable-key-revised\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2752\\\/rename-hashtable-key-revised\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2752\\\/rename-hashtable-key-revised\\\/\",\"name\":\"Rename Hashtable Key Revised &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2752\\\/rename-hashtable-key-revised\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2752\\\/rename-hashtable-key-revised\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/01\\\/rename-hashtable-paramsets-1024x319.png\",\"datePublished\":\"2013-01-24T14:54:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2752\\\/rename-hashtable-key-revised\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2752\\\/rename-hashtable-key-revised\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2752\\\/rename-hashtable-key-revised\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/01\\\/rename-hashtable-paramsets.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/01\\\/rename-hashtable-paramsets.png\",\"width\":1145,\"height\":357},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2752\\\/rename-hashtable-key-revised\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Rename Hashtable Key Revised\"}]},{\"@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":"Rename Hashtable Key Revised &#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\/2752\/rename-hashtable-key-revised\/","og_locale":"en_US","og_type":"article","og_title":"Rename Hashtable Key Revised &#8226; The Lonely Administrator","og_description":"Last week I posted an advanced PowerShell function to rename a hashtable key. As usual, the more I worked with it the more I realized it was missing something - namely the ability the take a pipelined object. My original version assumed you had saved the hashtable to a variable. But as I was working...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/","og_site_name":"The Lonely Administrator","article_published_time":"2013-01-24T14:54:16+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets-1024x319.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\/2752\/rename-hashtable-key-revised\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Rename Hashtable Key Revised","datePublished":"2013-01-24T14:54:16+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/"},"wordCount":306,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets-1024x319.png","keywords":["hashtable","parameter","Pipeline","PowerShell","Scripting"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/","name":"Rename Hashtable Key Revised &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets-1024x319.png","datePublished":"2013-01-24T14:54:16+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets.png","width":1145,"height":357},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Rename Hashtable Key Revised"}]},{"@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":2711,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2711\/rename-hashtable-key\/","url_meta":{"origin":2752,"position":0},"title":"Rename Hashtable Key","author":"Jeffery Hicks","date":"January 16, 2013","format":false,"excerpt":"I use hashtables quite a bit. Often generating hashtables on the fly from other sources. But sometimes the hashtable keys that come from these external sources don't align with what I intend to do with the hashtable. For example, one of the nifty things you can do with hashtables is\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"talkbubble","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3073,"url":"https:\/\/jdhitsolutions.com\/blog\/friday-fun\/3073\/friday-fun-view-objects-in-a-powershell-gridlist\/","url_meta":{"origin":2752,"position":1},"title":"Friday Fun: View Objects in a PowerShell GridList","author":"Jeffery Hicks","date":"May 24, 2013","format":false,"excerpt":"One of the things that makes PowerShell easy to learn is discoverability. Want to know more about a particular type of object? Pipe it to Get-Member. Or if you want to see values pipe it to Select-Object. get-ciminstance win32_computersystem | select * That's not too bad. Or you can pipe\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"Select-OutGridView","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/Select-OutGridView-300x72.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2733,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2733\/convert-powershell-object-to-hashtable-revised\/","url_meta":{"origin":2752,"position":2},"title":"Convert PowerShell Object to Hashtable Revised","author":"Jeffery Hicks","date":"January 22, 2013","format":false,"excerpt":"A while back I posted an advanced PowerShell function that would take an object and convert it to a hashtable. The premise was simple enough: look at the incoming object with Get-Member to discover the property names then create a hashtable with each property name as a hashtable key. I've\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"squarepattern","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/squarepattern-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3462,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3462\/friday-fun-out-conditionalcolor\/","url_meta":{"origin":2752,"position":3},"title":"Friday Fun: Out-ConditionalColor","author":"Jeffery Hicks","date":"September 27, 2013","format":false,"excerpt":"Last week I posted a Friday Fun article on parsing results from Invoke-Webrequest and displaying matching strings in color so that the book titles I'm interested in stand out. But the more I thought about it I realized I should take this a step further. The problem with Write-Host is\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"occ-basic","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/occ-basic-1024x638.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/occ-basic-1024x638.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/occ-basic-1024x638.png?resize=525%2C300 1.5x"},"classes":[]},{"id":2740,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/","url_meta":{"origin":2752,"position":4},"title":"Join PowerShell Hash Tables","author":"Jeffery Hicks","date":"January 23, 2013","format":false,"excerpt":"I received a lot of feedback and interest in my ConvertTo-Hashtable function. One question I received was \"Why?\" Well, one reason might be that you want to combine two objects into a single object. Joining them as two hashtables makes this an easier process. First off, combining two hashtables is\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"handshake","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/handshake.gif?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1701,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1701\/friday-fun-convert-object-to-hash-table\/","url_meta":{"origin":2752,"position":5},"title":"Friday Fun Convert Object to Hash Table","author":"Jeffery Hicks","date":"October 21, 2011","format":false,"excerpt":"I've been working on a few PowerShell projects recently and one requirement I had was to turn an object into a hash table. I thought this was something that was already handled in PowerShell but I couldn't find a cmdlet or an easy .NET technique. So I wrote my own\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":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2752","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=2752"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2752\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2752"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2752"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}