{"id":4800,"date":"2016-01-14T11:51:55","date_gmt":"2016-01-14T16:51:55","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=4800"},"modified":"2016-01-14T11:51:55","modified_gmt":"2016-01-14T16:51:55","slug":"testing-powershell-hashtables","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/","title":{"rendered":"Testing PowerShell HashTables"},"content":{"rendered":"<p>So I've been watching the <a href=\"https:\/\/www.pluralsight.com\/courses\/powershell-toolmaking-fundamentals\" target=\"_blank\">PowerShell Toolmaking Fundamentals<\/a> course on <a href=\"http:\/\/www.pluralsight.com\" target=\"_blank\">Pluralsight<\/a> authored by <a title=\"follow Adam on Twitter\" href=\"http:\/\/twitter.com\/adbertram\" target=\"_blank\">Adam Bertram<\/a>.\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 cool.\" I have found a few of these in Adam's course so far.<\/p>\n<p>One of the tricks he demonstrated was using a hashtable as a parameter value for an advanced function that could then be splatted to <a title=\"get help for this command online\" href=\"http:\/\/go.microsoft.com\/fwlink\/p\/?linkid=291132\" target=\"_blank\">Set-ADuser<\/a>.\u00a0 For the sake of what I want to demonstrate here's my simplified version of such a function.<\/p>\n<pre class=\"lang:ps decode:true \">Function Update-MyUser {\r\n[cmdletbinding(SupportsShouldProcess)]\r\nParam(\r\n[Parameter(Position = 0, Mandatory, HelpMessage = \"Enter a user name\")]\r\n[ValidateNotNullorEmpty()]\r\n[Microsoft.ActiveDirectory.Management.ADUser]$Identity,\r\n[Parameter(Position = 1, Mandatory, HelpMessage = \"Enter a hashtable of parameter values for Set-ADUser\")]\r\n[ValidateNotNullorEmpty()]\r\n[hashtable]$Settings\r\n)\r\n\r\nWrite-Verbose \"Updating $Identity\"\r\n\r\nWrite-Verbose ($Settings | Out-String)\r\nTry {\r\n$user = Get-ADuser $Identity -ErrorAction stop\r\nWrite-Verbose $user.distinguishedname\r\n}\r\nCatch {\r\nThrow $_\r\n}\r\n\r\n#splat the settings hashtable to Set-ADuUser\r\n\r\n$user| Set-ADUser @settings\r\n\r\n}\r\n\r\n<\/pre>\n<p>The function gets the specified user and then updates the user with hashtable of parameters from Set-ADUser.\u00a0 If you know all the parameter names this works just fine.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-4.png\" alt=\"image\" width=\"644\" height=\"286\" border=\"0\" \/><\/a><\/p>\n<p>I've easily updated the user account.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-5.png\" alt=\"image\" width=\"644\" height=\"177\" border=\"0\" \/><\/a><\/p>\n<p>But what if I make a mistake with the hashtable of settings?<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-6.png\" alt=\"image\" width=\"644\" height=\"210\" border=\"0\" \/><\/a><\/p>\n<p>There is no parameter called FirstName for Set-ADUser. It should be GivenName. One thing you could do, and this is the point of this article,\u00a0 is to\u00a0 validate the hashtable keys against parameter names from Set-ADuser.<\/p>\n<p>You can use <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113309\" target=\"_blank\">Get-Command<\/a> to list all of the parameter names.<\/p>\n<pre class=\"lang:ps decode:true \">get-command Set-ADuser | Select -expand Parameters<\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-7.png\" alt=\"image\" width=\"644\" height=\"232\" border=\"0\" \/><\/a><\/p>\n<p>What we need to do is make sure that all of the keys in the settings hashtable are in this list. Here's a quick test.<\/p>\n<pre class=\"lang:ps decode:true \">$s = @{Title=\"T\";Description=\"d\"}\r\n$p = get-command set-aduser | select -expand parameters<\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image-8.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-8.png\" alt=\"image\" width=\"309\" height=\"262\" border=\"0\" \/><\/a><\/p>\n<p>I can use code like this to test if the keys from $s are also in $p:<\/p>\n<pre class=\"lang:ps decode:true \">$s.keys | where {$p.keys -contains $_}<\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image-9.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-9.png\" alt=\"image\" width=\"601\" height=\"108\" border=\"0\" \/><\/a><\/p>\n<p>Although I may be more interested in the cases where they don't match.<\/p>\n<pre class=\"lang:ps decode:true \">$s.keys | where {$p.keys -notcontains $_}<\/pre>\n<p>This won't give any results because nothing matches the filter. But if I modify the hashtable with a bogus entry it will.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image-10.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-10.png\" alt=\"image\" width=\"596\" height=\"101\" border=\"0\" \/><\/a><\/p>\n<p>With this concept in mind I can revise the function.<\/p>\n<pre class=\"lang:ps mark:12-15,34 decode:true\">Function Update-MyUser {\r\n[cmdletbinding(SupportsShouldProcess)]\r\nParam(\r\n[Parameter(Position = 0, Mandatory, HelpMessage = \"Enter a user name\")]\r\n[ValidateNotNullorEmpty()]\r\n[Microsoft.ActiveDirectory.Management.ADUser]$Identity,\r\n[Parameter(Position = 1, Mandatory, HelpMessage = \"Enter a hashtable of parameter values for Set-ADUser\")]\r\n[ValidateNotNullorEmpty()]\r\n[hashtable]$Settings\r\n)\r\n\r\n#get parameters for Set-ADUser\r\n$setparams = Get-Command -Name Set-ADuser | Select -ExpandProperty Parameters\r\n#get keys from Settings that aren't in $SetParams.\r\n$bad = $settings.Keys | where {$setparams.keys -notcontains $_ }\r\n\r\nif (-Not $Bad) {\r\n\r\nWrite-Verbose \"Updating $Identity\"\r\n\r\nWrite-Verbose ($Settings | Out-String)\r\nTry {\r\n$user = Get-ADuser $Identity -ErrorAction stop\r\nWrite-Verbose $user.distinguishedname\r\n}\r\nCatch {\r\nThrow $_\r\n}\r\n\r\n$user| Set-ADUser @settings\r\n\r\n}\r\nelse {\r\nWrite-Warning \"The Settings hashtable contains these bad keys: $($bad -join \",\")\"\r\n}\r\n}\r\n\r\n<\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image-11.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-11.png\" alt=\"image\" width=\"644\" height=\"41\" border=\"0\" \/><\/a><\/p>\n<p>Certainly you could add other code to list the available parameters, suggest corrections or whatever. But now the function won't attempt to run and gracefully handles bad keys.<\/p>\n<p>Once corrected, the function works as expected.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image-12.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-12.png\" alt=\"image\" width=\"644\" height=\"154\" border=\"0\" \/><\/a><\/p>\n<p>And please don't take any of this as an indication that Adam missed something in his course. Far from it.\u00a0 No course can teach you absolutely everything you need to know to build effective PowerShell tools. You need to build what works for you and add error handling that you feel is appropriate. In this case I thought this would offer a nice learning opportunity for you to learn about hashtable keys and a few operators.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I&#8217;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&#8217;t know about, find a new teaching technique or something else that makes me say, &#8220;that was cool.&#8221; I have found a&#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":"New from the blog: Testing #PowerShell HashTables","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,8],"tags":[199,578,534,540],"class_list":["post-4800","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-hashtable","tag-pluralsight","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>Testing PowerShell HashTables &#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\/4800\/testing-powershell-hashtables\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Testing PowerShell HashTables &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"So I&#039;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&#039;t know about, find a new teaching technique or something else that makes me say, &quot;that was cool.&quot; I have found a...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-14T16:51:55+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-4.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=\"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\\\/4800\\\/testing-powershell-hashtables\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4800\\\/testing-powershell-hashtables\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Testing PowerShell HashTables\",\"datePublished\":\"2016-01-14T16:51:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4800\\\/testing-powershell-hashtables\\\/\"},\"wordCount\":409,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4800\\\/testing-powershell-hashtables\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/01\\\/image_thumb-4.png\",\"keywords\":[\"hashtable\",\"Pluralsight\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4800\\\/testing-powershell-hashtables\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4800\\\/testing-powershell-hashtables\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4800\\\/testing-powershell-hashtables\\\/\",\"name\":\"Testing PowerShell HashTables &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4800\\\/testing-powershell-hashtables\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4800\\\/testing-powershell-hashtables\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/01\\\/image_thumb-4.png\",\"datePublished\":\"2016-01-14T16:51:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4800\\\/testing-powershell-hashtables\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4800\\\/testing-powershell-hashtables\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4800\\\/testing-powershell-hashtables\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/01\\\/image_thumb-4.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/01\\\/image_thumb-4.png\",\"width\":644,\"height\":286},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4800\\\/testing-powershell-hashtables\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Testing PowerShell HashTables\"}]},{\"@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":"Testing PowerShell HashTables &#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\/4800\/testing-powershell-hashtables\/","og_locale":"en_US","og_type":"article","og_title":"Testing PowerShell HashTables &#8226; The Lonely Administrator","og_description":"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 cool.\" I have found a...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/","og_site_name":"The Lonely Administrator","article_published_time":"2016-01-14T16:51:55+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-4.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":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Testing PowerShell HashTables","datePublished":"2016-01-14T16:51:55+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/"},"wordCount":409,"commentCount":4,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-4.png","keywords":["hashtable","Pluralsight","PowerShell","Scripting"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/","name":"Testing PowerShell HashTables &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-4.png","datePublished":"2016-01-14T16:51:55+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-4.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/01\/image_thumb-4.png","width":644,"height":286},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4800\/testing-powershell-hashtables\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Testing PowerShell HashTables"}]},{"@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":3824,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3824\/happy-birthday-pluralsight\/","url_meta":{"origin":4800,"position":0},"title":"Happy Birthday Pluralsight","author":"Jeffery Hicks","date":"April 23, 2014","format":false,"excerpt":"Pluralsight is celebrating its 10th birthday today. As part of their celebration they are running a quick contest with a cool prize. They also asked authors for a birthday greeting or message. Since all of my courses are PowerShell related it seemed only fitting to do something like this: Sure,\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":6275,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6275\/powershell-updown-prompt\/","url_meta":{"origin":4800,"position":1},"title":"A PowerShell Up\/Down Prompt","author":"Jeffery Hicks","date":"December 11, 2018","format":false,"excerpt":"It appears many of you are taken with the possibilities of PowerShell prompt functions. In previous posts, I alluded to the fact that you could do just about anything in a prompt function. Today I have an example of what I am talking about. The challenging part of creating a\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\/2018\/12\/image_thumb-7.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-7.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-7.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":4693,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4693\/computer-certificate-tools\/","url_meta":{"origin":4800,"position":2},"title":"Computer Certificate tools","author":"Jeffery Hicks","date":"December 21, 2015","format":false,"excerpt":"In my Pluralsight course on Advanced DSC I used a few functions I wrote to make it easier to work with computer certificates. If you need to encrypt things like passwords in a DSC configuration,\u00a0 you must some type of certificate thumbprint as well as a copy of the certificate.\u2026","rel":"","context":"In &quot;DSC&quot;","block_context":{"text":"DSC","link":"https:\/\/jdhitsolutions.com\/blog\/category\/dsc\/"},"img":{"alt_text":"Exporting a certificate","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/12\/image_thumb-4.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/12\/image_thumb-4.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/12\/image_thumb-4.png?resize=525%2C300 1.5x"},"classes":[]},{"id":8821,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8821\/friday-fun-redacting-with-powershell\/","url_meta":{"origin":4800,"position":3},"title":"Friday Fun: Redacting with PowerShell","author":"Jeffery Hicks","date":"January 28, 2022","format":false,"excerpt":"It has been a while since my last Friday Fun post. These are articles that use PowerShell in fun and off-beat ways. The goal is to demonstrate techniques and concepts not necessarily give you something ready for production. Today, I'm going to modify PowerShell output to hide, or redact, potentially\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\/01\/or-3.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/or-3.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/or-3.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3861,"url":"https:\/\/jdhitsolutions.com\/blog\/training\/3861\/new-powershell-pluralsight-course\/","url_meta":{"origin":4800,"position":4},"title":"New PowerShell Pluralsight Course","author":"Jeffery Hicks","date":"May 23, 2014","format":false,"excerpt":"I am so happy to announce that my first course under the Pluralsight badge has been released. My latest course is titled PowerShell v4 New Features. This course is aimed at IT Pros with previous experience using PowerShell, especially PowerShell v3. The course runs just under 3 hours (although it\u2026","rel":"","context":"In &quot;Pluralsight&quot;","block_context":{"text":"Pluralsight","link":"https:\/\/jdhitsolutions.com\/blog\/category\/pluralsight\/"},"img":{"alt_text":"WatermarkLogo151x79","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/05\/WatermarkLogo151x79.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2740,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2740\/join-powershell-hash-tables\/","url_meta":{"origin":4800,"position":5},"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":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4800","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=4800"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4800\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4800"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4800"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}