{"id":2740,"date":"2013-01-23T11:01:23","date_gmt":"2013-01-23T16:01:23","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=2740"},"modified":"2013-01-23T11:01:23","modified_gmt":"2013-01-23T16:01:23","slug":"join-powershell-hash-tables","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/","title":{"rendered":"Join PowerShell Hash Tables"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/handshake.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/handshake.gif\" alt=\"handshake\" width=\"147\" height=\"131\" class=\"alignleft size-full wp-image-2745\" \/><\/a>I received a lot of feedback and interest in my <a href=\"http:\/\/jdhitsolutions.com\/blog\/2013\/01\/convert-powershell-object-to-hashtable-revised\/\" target=\"_blank\">ConvertTo-Hashtable<\/a> 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.  <\/p>\n<p>First off, combining two hashtables is as simple as adding them together.<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS C:\\> $a=@{Name=\"Jeff\";Count=3;Color=\"Green\"}<br \/>\nPS C:\\> $b=@{Computer=\"HAL\";Enabled=$True;Year=2020}<br \/>\nPS C:\\> $a+$b<\/p>\n<p>Name                           Value<br \/>\n----                           -----<br \/>\nName                           Jeff<br \/>\nColor                          Green<br \/>\nYear                           2020<br \/>\nComputer                       HAL<br \/>\nCount                          3<br \/>\nEnabled                        True<br \/>\n<\/code><\/p>\n<p>This works fine as long as there are no duplicate keys.<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS C:\\> $b=@{Computer=\"HAL\";Enabled=$True;Year=2020;Color=\"Red\"}<br \/>\nPS C:\\> $a+$b<br \/>\n+ : Bad argument to operator '+': Item has already been added. Key in dictionary: 'Color'  Key bein<br \/>\ng added: 'Color'.<br \/>\nAt line:1 char:4<br \/>\n+ $a+ <<<< $b\n    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException\n    + FullyQualifiedErrorId : BadOperatorArgument\n<\/code><\/p>\n<p>So as part of my continued fun with hashtables, I decided to put together a function to join hashtables and handle these key conflicts.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\nFunction Join-Hashtable {<\/p>\n<p>#comment based help is here<br \/>\n[cmdletbinding()]<br \/>\nParam (<br \/>\n[hashtable]$First,<br \/>\n[hashtable]$Second,<br \/>\n[switch]$Force<br \/>\n)<\/p>\n<p>#create clones of hashtables so originals are not modified<br \/>\n$Primary = $First.Clone()<br \/>\n$Secondary = $Second.Clone()<\/p>\n<p>#check for any duplicate keys<br \/>\n$duplicates = $Primary.keys | where {$Secondary.ContainsKey($_)}<br \/>\nif ($duplicates) {<br \/>\n    foreach ($item in $duplicates) {<br \/>\n        if ($force) {<br \/>\n            #force primary key, so remove secondary conflict<br \/>\n            $Secondary.Remove($item)<br \/>\n        }<br \/>\n        else {<br \/>\n            Write-Host \"Duplicate key $item\" -ForegroundColor Yellow<br \/>\n            Write-Host \"A $($Primary.Item($item))\" -ForegroundColor Yellow<br \/>\n            Write-host \"B $($Secondary.Item($item))\" -ForegroundColor Yellow<br \/>\n            $r = Read-Host \"Which key do you want to KEEP [AB]?\"<br \/>\n            if ($r -eq \"A\") {<br \/>\n                $Secondary.Remove($item)<br \/>\n            }<br \/>\n            elseif ($r -eq \"B\") {<br \/>\n                $Primary.Remove($item)<br \/>\n            }<br \/>\n            Else {<br \/>\n                Write-Warning \"Aborting operation\"<br \/>\n                Return<br \/>\n            }<br \/>\n        } #else prompt<br \/>\n   }<br \/>\n}<\/p>\n<p>#join the two hash tables<br \/>\n$Primary+$Secondary<\/p>\n<p>} #end Join-Hashtable<br \/>\n<\/code><\/p>\n<p>The function takes two hash tables and attempts to join them together. Because I might be removing duplicate keys, I didn't want to change the original hashtables so I first create clones.<\/p>\n<p><code Lang=\"PowerShell\"><br \/>\n$Primary = $First.Clone()<br \/>\n$Secondary = $Second.Clone()<br \/>\n<\/code><\/p>\n<p>If I didn't, removing a key from $Primary would also remove it from the original hashtable. Next, I check to see if any of the keys from the first hashtable are also in the second hashtable.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\n$duplicates = $Primary.keys | where {$Secondary.ContainsKey($_)}<br \/>\n<\/code><\/p>\n<p>If there are none, I simply add the two hashtables together and write the result to the pipeline. But if there are duplicates, and there could be more than one, the function will prompt you for which one to keep and then remove the item from the other hashtable.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\n Write-Host \"Duplicate key $item\" -ForegroundColor Yellow<br \/>\n Write-Host \"A $($Primary.Item($item))\" -ForegroundColor Yellow<br \/>\n Write-host \"B $($Secondary.Item($item))\" -ForegroundColor Yellow<br \/>\n $r = Read-Host \"Which key do you want to KEEP [AB]?\"<br \/>\n if ($r -eq \"A\") {<br \/>\n    $Secondary.Remove($item)<br \/>\n }<br \/>\n elseif ($r -eq \"B\") {<br \/>\n    $Primary.Remove($item)<br \/>\n }<br \/>\n<\/code><\/p>\n<p>Once the duplicates are removed, I can go ahead and add the two together. But since I might not always want to be prompted, I added a -Force parameter which will keep any duplicates from the first hashtable without any prompting. So now, I can combine hashtables like this:<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS C:\\> join-hashtable $a $b<br \/>\nDuplicate key Color<br \/>\nA Green<br \/>\nB Red<br \/>\nWhich key do you want to KEEP [AB]?: a<\/p>\n<p>Name                           Value<br \/>\n----                           -----<br \/>\nName                           Jeff<br \/>\nColor                          Green<br \/>\nYear                           2020<br \/>\nComputer                       HAL<br \/>\nCount                          3<br \/>\nEnabled                        True<br \/>\n<\/code><\/p>\n<p>Or force the first hashtable.<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS C:\\> join-hashtable $a $b -Force<\/p>\n<p>Name                           Value<br \/>\n----                           -----<br \/>\nName                           Jeff<br \/>\nColor                          Green<br \/>\nYear                           2020<br \/>\nComputer                       HAL<br \/>\nCount                          3<br \/>\nEnabled                        True<br \/>\n<\/code><\/p>\n<p>But $a and $b are never modified. Now to combine things.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\n$os = get-wmiobject win32_operatingsystem |<br \/>\nSelect Caption,@{Name=\"computername\";Expression={$_.CSName}},<br \/>\nOSArchitecture,ServicePackMajorVersion | ConvertTo-HashTable<\/p>\n<p>$cs = Get-WmiObject win32_computersystem |<br \/>\nSelect Manufacturer,Model,TotalPhysicalMemory |<br \/>\nConvertTo-HashTable<\/p>\n<p>New-object -TypeName PSObject -Property (Join-Hashtable $os $cs)<\/p>\n<p>TotalPhysicalMemory     : 8577851392<br \/>\nManufacturer            : TOSHIBA<br \/>\ncomputername            : SERENITY<br \/>\nOSArchitecture          : 64-bit<br \/>\nModel                   : Qosmio X505<br \/>\nCaption                 : Microsoft Windows 8 Pro<br \/>\nServicePackMajorVersion : 0<br \/>\n<\/code><\/p>\n<p>I took two different WMI classes and created a single object. Yes, I realize there are any number of ways of accomplishing the same task. In this case I could have also simply run $os+$cs because I knew ahead of time there would be no conflicting keys. Here's a variation for PowerShell 3.0.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\n$exclude = \"__*\",\"Scope\",\"Path\",\"Options\",\"ClassPath\",\"*Properties\",\"Qualifiers\"<\/p>\n<p>$os = get-wmiobject win32_operatingsystem |<br \/>\nSelect * -ExcludeProperty $exclude | ConvertTo-HashTable -NoEmpty<\/p>\n<p>$cs = get-wmiobject win32_computersystem |<br \/>\nSelect * -ExcludeProperty $exclude | ConvertTo-HashTable -NoEmpty<\/p>\n<p>$final = [pscustomobject](Join-Hashtable $os $cs -Force)<br \/>\n<\/code><\/p>\n<p>This gets all properties from the 2 WMI classes, except for the exceptions, that have a value. I then combine the two and create a new object. If there are any conflicts the $os hashtable will \"win\".<\/p>\n<p>I'm sure there are other situations where you might want to convert objects to hashtables, or join hashtables. I hope you'll let me know how you use these tools.  In the meantime, download <a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/Join-Hashtable.txt\" target=\"_blank\">Join-Hashtable<\/a>. It should work in PowerShell 2.0 or 3.0.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I received a lot of feedback and interest in my ConvertTo-Hashtable function. One question I received was &#8220;Why?&#8221; 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 as simple as adding them&#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,534,540],"class_list":["post-2740","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-hashtable","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>Join PowerShell Hash Tables &#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\/2740\/join-powershell-hash-tables\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Join PowerShell Hash Tables &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I received a lot of feedback and interest in my ConvertTo-Hashtable function. One question I received was &quot;Why?&quot; 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 as simple as adding them...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2013-01-23T16:01:23+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/handshake.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=\"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\\\/2740\\\/join-powershell-hash-tables\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2740\\\/join-powershell-hash-tables\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Join PowerShell Hash Tables\",\"datePublished\":\"2013-01-23T16:01:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2740\\\/join-powershell-hash-tables\\\/\"},\"wordCount\":411,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2740\\\/join-powershell-hash-tables\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/01\\\/handshake.gif\",\"keywords\":[\"hashtable\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2740\\\/join-powershell-hash-tables\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2740\\\/join-powershell-hash-tables\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2740\\\/join-powershell-hash-tables\\\/\",\"name\":\"Join PowerShell Hash Tables &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2740\\\/join-powershell-hash-tables\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2740\\\/join-powershell-hash-tables\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/01\\\/handshake.gif\",\"datePublished\":\"2013-01-23T16:01:23+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2740\\\/join-powershell-hash-tables\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2740\\\/join-powershell-hash-tables\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2740\\\/join-powershell-hash-tables\\\/#primaryimage\",\"url\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/01\\\/handshake.gif\",\"contentUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/01\\\/handshake.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2740\\\/join-powershell-hash-tables\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Join PowerShell Hash Tables\"}]},{\"@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":"Join PowerShell Hash Tables &#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\/2740\/join-powershell-hash-tables\/","og_locale":"en_US","og_type":"article","og_title":"Join PowerShell Hash Tables &#8226; The Lonely Administrator","og_description":"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 as simple as adding them...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/","og_site_name":"The Lonely Administrator","article_published_time":"2013-01-23T16:01:23+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/handshake.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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Join PowerShell Hash Tables","datePublished":"2013-01-23T16:01:23+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/"},"wordCount":411,"commentCount":3,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/handshake.gif","keywords":["hashtable","PowerShell","Scripting"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/","name":"Join PowerShell Hash Tables &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/handshake.gif","datePublished":"2013-01-23T16:01:23+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/#primaryimage","url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/handshake.gif","contentUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/handshake.gif"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Join PowerShell Hash Tables"}]},{"@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":2740,"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":2733,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2733\/convert-powershell-object-to-hashtable-revised\/","url_meta":{"origin":2740,"position":1},"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":4039,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4039\/sorting-hash-tables\/","url_meta":{"origin":2740,"position":2},"title":"Sorting Hash Tables","author":"Jeffery Hicks","date":"September 22, 2014","format":false,"excerpt":"Over the weekend I received a nice comment from a reader who came across an old post of mine on turning an object into a hash table.\u00a0 He wanted to add a comment but my blog closes comments after a period of time. But I thought it was worth sharing,\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"letterjumble","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/03\/letterjumble-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4800,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/","url_meta":{"origin":2740,"position":3},"title":"Testing PowerShell HashTables","author":"Jeffery Hicks","date":"January 14, 2016","format":false,"excerpt":"So I've been watching the PowerShell Toolmaking Fundamentals course on Pluralsight authored by Adam Bertram.\u00a0 You may be surprised that I watch other PowerShell related courses, but I always pick up something I didn't know about, find a new teaching technique or something else that makes me say, \"that was\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\/2016\/01\/image_thumb-4.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-4.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-4.png?resize=525%2C300 1.5x"},"classes":[]},{"id":654,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/654\/new-wmi-object\/","url_meta":{"origin":2740,"position":4},"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":3073,"url":"https:\/\/jdhitsolutions.com\/blog\/friday-fun\/3073\/friday-fun-view-objects-in-a-powershell-gridlist\/","url_meta":{"origin":2740,"position":5},"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":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2740","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=2740"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2740\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}