{"id":1701,"date":"2011-10-21T10:13:07","date_gmt":"2011-10-21T14:13:07","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=1701"},"modified":"2013-09-13T09:02:53","modified_gmt":"2013-09-13T13:02:53","slug":"friday-fun-convert-object-to-hash-table","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1701\/friday-fun-convert-object-to-hash-table\/","title":{"rendered":"Friday Fun Convert Object to Hash Table"},"content":{"rendered":"<p>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 function, ConvertTo-Hashtable.<\/p>\n<p>The function is designed to accept pipelined input and turns each object into an associative array, i.e., a hash table, and write the hash table to the pipeline.<\/p>\n<pre class=\"lang:ps decode:true\">Function ConvertTo-HashTable {\r\n\r\n[cmdletbinding()]\r\n\r\nParam(\r\n[Parameter(Position=0,Mandatory=$True,HelpMessage=\"Please specify an object\",\r\nValueFromPipeline=$True)]\r\n[object]$InputObject,\r\n[switch]$NoEmpty\r\n)\r\n\r\nProcess {\r\nWrite-Verbose \"Converting an object of type $($_.GetType().Name)\"\r\n#get propery names\r\n$names=$InputObject | get-member -MemberType properties | select-object -expandproperty name\r\n#define an empty hash table\r\n$hash=@{}\r\n#go through the list of names and add each property and value to the hash table\r\n$names | foreach-object {\r\nWrite-Verbose \"Adding property $_\"\r\n$hash.Add($_,$inputobject.$_)\r\n} #foreach\r\nif ($noEmpty) {\r\nWrite-Verbose \"Parsing out empty values\"\r\n#define a new hash\r\n$defined=@{}\r\n#get items from $hash that have values and add to $defined\r\n$hash.keys | foreach-object {\r\nif ($hash.item($_)) {\r\n$defined.add($_,$hash.item($_))\r\n}\r\n}\r\nWrite-Verbose \"Writing the result to the pipeline\"\r\nWrite-Output $defined\r\n}\r\nelse {\r\nWrite-Verbose \"Writing the result to the pipeline\"\r\nWrite-Output $hash\r\n} #If $noempty\r\n}#close process\r\n}#end function<\/pre>\n<p><span style=\"line-height: 1.714285714; font-size: 1rem;\">As an object is processed by the function it uses Get-Member to retrieve all of the object's properties.<\/span><\/p>\n<pre class=\"lang:ps decode:true\">$names=$InputObject | get-member -MemberType properties | select-object -expandproperty name<\/pre>\n<p><span style=\"line-height: 1.714285714; font-size: 1rem;\">The function then walks the object and adds each property name and value to a hash table.<\/span><\/p>\n<pre class=\"lang:ps decode:true\">#go through the list of names and add each property and value to the hash table\r\n$names | foreach-object {\r\nWrite-Verbose \"Adding property $_\"\r\n$hash.Add($_,$inputobject.$_)\r\n} #foreach<\/pre>\n<p><span style=\"line-height: 1.714285714; font-size: 1rem;\">This hash table object, $hash, eventually is written to the pipeline. This process happens to each piped in object. However, I also added a function parameter, -NoEmpty, to filter out properties with no values. When specified, the function creates a second hash table and then checks each key in $hash. If the corresponding item has a value, the key and value are added to the secondary hash.<\/span><\/p>\n<pre class=\"lang:ps decode:true crayon-selected\">if ($noEmpty) {\r\nWrite-Verbose \"Parsing out empty values\"\r\n#define a new hash\r\n$defined=@{}\r\n#get items from $hash that have values and add to $defined\r\n$hash.keys | foreach-object {\r\nif ($hash.item($_)) {\r\n$defined.add($_,$hash.item($_))\r\n}\r\n}\r\nWrite-Verbose \"Writing the result to the pipeline\"\r\nWrite-Output $defined<\/pre>\n<p>The secondary hash is then written to the pipeline. I had to take this approach because PowerShell doesn't like it when you try to modify and enumerate a hash table at the same time. Here's how you might use it:<\/p>\n<pre class=\"lang:batch decode:true\">PS S:\\&gt; $h=get-service spooler | convertto-hashtable\r\nPS S:\\&gt; $h\r\n\r\nName Value\r\n---- -----\r\nServiceName spooler\r\nCanPauseAndContinue False\r\nDisplayName Print Spooler\r\nCanShutdown False\r\nSite\r\nName spooler\r\nMachineName .\r\nServiceType Win32OwnProcess, InteractiveProcess\r\nStatus Running\r\nServiceHandle SafeServiceHandle\r\nContainer\r\nDependentServices {}\r\nRequiredServices {HTTP, RPCSS}\r\nServicesDependedOn {HTTP, RPCSS}\r\nCanStop True<\/pre>\n<p><span style=\"line-height: 1.714285714; font-size: 1rem;\">Or to filter out the empty values:<\/span><\/p>\n<pre class=\"lang:batch decode:true \">PS S:\\&gt; get-service spooler | convertto-hashtable -NoEmpty\r\n\r\nName Value\r\n---- -----\r\nServiceName spooler\r\nDisplayName Print Spooler\r\nRequiredServices {HTTP, RPCSS}\r\nName spooler\r\nMachineName .\r\nStatus Running\r\nServiceHandle SafeServiceHandle\r\nServiceType Win32OwnProcess, InteractiveProcess\r\nServicesDependedOn {HTTP, RPCSS}\r\nCanStop True<\/pre>\n<p><span style=\"line-height: 1.714285714; font-size: 1rem;\">Granted, your use case for something like this is probably pretty limited. But there are some good technique examples here on working with hash tables.<\/span><\/p>\n<p>The one nagging problem, at least until PowerShell v3, is that it is very difficult to write a sorted hash table. I'd love to write the hash table to the pipeline with sorted keys, but that may have to wait.<\/p>\n<p>In the meantime, feel free to download and experiment with <a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/ConvertTo-Hashtable.txt\" target=\"_blank\">ConvertTo-Hashtable<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;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&#8217;t find a cmdlet or an easy .NET technique. So I wrote my own function, ConvertTo-Hashtable. The function is&#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,61,4],"tags":[224,317,199,144,534],"class_list":["post-1701","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-miscellaneous","category-powershell","tag-function","tag-get-member","tag-hashtable","tag-objects","tag-powershell"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun Convert Object to Hash Table &#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\/1701\/friday-fun-convert-object-to-hash-table\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun Convert Object to Hash Table &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I&#039;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&#039;t find a cmdlet or an easy .NET technique. So I wrote my own function, ConvertTo-Hashtable. The function is...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/1701\/friday-fun-convert-object-to-hash-table\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2011-10-21T14:13:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-09-13T13:02:53+00:00\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1701\\\/friday-fun-convert-object-to-hash-table\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1701\\\/friday-fun-convert-object-to-hash-table\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun Convert Object to Hash Table\",\"datePublished\":\"2011-10-21T14:13:07+00:00\",\"dateModified\":\"2013-09-13T13:02:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1701\\\/friday-fun-convert-object-to-hash-table\\\/\"},\"wordCount\":319,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"Function\",\"get-member\",\"hashtable\",\"objects\",\"PowerShell\"],\"articleSection\":[\"Friday Fun\",\"Miscellaneous\",\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1701\\\/friday-fun-convert-object-to-hash-table\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1701\\\/friday-fun-convert-object-to-hash-table\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1701\\\/friday-fun-convert-object-to-hash-table\\\/\",\"name\":\"Friday Fun Convert Object to Hash Table &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2011-10-21T14:13:07+00:00\",\"dateModified\":\"2013-09-13T13:02:53+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1701\\\/friday-fun-convert-object-to-hash-table\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1701\\\/friday-fun-convert-object-to-hash-table\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1701\\\/friday-fun-convert-object-to-hash-table\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun Convert Object to Hash Table\"}]},{\"@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 Convert Object to Hash Table &#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\/1701\/friday-fun-convert-object-to-hash-table\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun Convert Object to Hash Table &#8226; The Lonely Administrator","og_description":"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 function, ConvertTo-Hashtable. The function is...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1701\/friday-fun-convert-object-to-hash-table\/","og_site_name":"The Lonely Administrator","article_published_time":"2011-10-21T14:13:07+00:00","article_modified_time":"2013-09-13T13:02:53+00:00","author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1701\/friday-fun-convert-object-to-hash-table\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1701\/friday-fun-convert-object-to-hash-table\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun Convert Object to Hash Table","datePublished":"2011-10-21T14:13:07+00:00","dateModified":"2013-09-13T13:02:53+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1701\/friday-fun-convert-object-to-hash-table\/"},"wordCount":319,"commentCount":3,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["Function","get-member","hashtable","objects","PowerShell"],"articleSection":["Friday Fun","Miscellaneous","PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/1701\/friday-fun-convert-object-to-hash-table\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1701\/friday-fun-convert-object-to-hash-table\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1701\/friday-fun-convert-object-to-hash-table\/","name":"Friday Fun Convert Object to Hash Table &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2011-10-21T14:13:07+00:00","dateModified":"2013-09-13T13:02:53+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1701\/friday-fun-convert-object-to-hash-table\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/1701\/friday-fun-convert-object-to-hash-table\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1701\/friday-fun-convert-object-to-hash-table\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"Friday Fun Convert Object to Hash Table"}]},{"@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":2733,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2733\/convert-powershell-object-to-hashtable-revised\/","url_meta":{"origin":1701,"position":0},"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":2752,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2752\/rename-hashtable-key-revised\/","url_meta":{"origin":1701,"position":1},"title":"Rename Hashtable Key Revised","author":"Jeffery Hicks","date":"January 24, 2013","format":false,"excerpt":"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.\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"rename-hashtable-paramsets","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets-1024x319.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets-1024x319.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/rename-hashtable-paramsets-1024x319.png?resize=525%2C300 1.5x"},"classes":[]},{"id":3462,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3462\/friday-fun-out-conditionalcolor\/","url_meta":{"origin":1701,"position":2},"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":1701,"position":3},"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":654,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/654\/new-wmi-object\/","url_meta":{"origin":1701,"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":1701,"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\/1701","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=1701"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1701\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}