{"id":7937,"date":"2020-12-08T12:03:24","date_gmt":"2020-12-08T17:03:24","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=7937"},"modified":"2020-12-08T12:03:30","modified_gmt":"2020-12-08T17:03:30","slug":"creating-powershell-property-names","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/","title":{"rendered":"Creating PowerShell Property Names"},"content":{"rendered":"\n<p>The last week or so I've been playing with a new PowerShell project from <a href=\"https:\/\/powershell.anovelidea.org\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Dave Carroll <\/a>for using Twitter from a PowerShell prompt. The module is called <a href=\"https:\/\/bluebirdps.anovelidea.org\/en\/latest\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">BluebirdPS<\/a> and you can install it from the PowerShell Gallery. The module is very much still in its early stages but is functional and intriguing. The reason you might find this interesting is not so much Twitter, but how Dave leverages the Twitter APIs. You might find yourself working with a different API to build a PowerShell-based tool. As you tackle these projects, you always want to be thinking about \"objects in the pipeline\", and part of that means creating proper PowerShell property names.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Make It User Friendly<\/h2>\n\n\n\n<p>When you build a PowerShell tool, you want the output to be easy to use. To me, this means having clearly defined property names. Dave has a command in the module to get a Twitter user account. Here's what it currently writes to the pipeline.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"405\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/get-twitteruser-1024x405.png\" alt=\"get-twitteruser\" class=\"wp-image-7938\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/get-twitteruser-1024x405.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/get-twitteruser-300x119.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/get-twitteruser-768x304.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/get-twitteruser-1536x607.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/get-twitteruser-2048x810.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/get-twitteruser-850x336.png 850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>For the sake of demonstration, assume that the Get-TwitterUser command is your code that is invoking a REST API and returning a custom object to the pipeline. <\/p>\n\n\n\n<p>The property names are mostly clear, although not very PowerShell friendly. How many native PowerShell commands do you run that have properties that look like this? Let's fix this.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Convert-PropertyName<\/h2>\n\n\n\n<p>Some property names are multi-word using an underscore as a delimiter. This is typical, but I suppose some API might create a property like <em>default-profile<\/em>. In PowerShell, I'd argue that a better property name would be <em>DefaultProfile<\/em>. Here's one way to change it.<\/p>\n\n\n\n<p>First, let me get a sample object.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\"> $me = Get-TwitterUser -ScreenName jeffhicks<\/code><\/pre>\n\n\n\n<p>How do I get the property names? PowerShell does a lot of abstraction under-the-hood to make it easy to use. The object represented by $me has another layer.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"241\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/psobject-1024x241.png\" alt=\"psobject\" class=\"wp-image-7939\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/psobject-1024x241.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/psobject-300x71.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/psobject-768x181.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/psobject-1536x361.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/psobject-2048x482.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/psobject-850x200.png 850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The properties collection can be quite useful.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1020\" height=\"806\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/psobject-properites.png\" alt=\"psobject properties\" class=\"wp-image-7940\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/psobject-properites.png 1020w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/psobject-properites-300x237.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/psobject-properites-768x607.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/psobject-properites-850x672.png 850w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><\/figure>\n\n\n\n<p>To \"re-define\" the property name, walk through the process in your head or write it out.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Split the name on  the _ delimiter<\/li><li>For each element in the array capitalize the first letter<\/li><li>Join the array back to a single string with no spaces.<\/li><\/ul>\n\n\n\n<p>I need a PowerShell function to achieve this task. As you can hopefully see from my list, I've practically written the core code.<\/p>\n\n\n\n<pre class=\"wp-block-code\" title=\"Convert-Property\"><code lang=\"powershell\" class=\"language-powershell\">Function Convert-PropertyName {\n    Param(\n        [Parameter(Mandatory)]\n        [string]$Name,\n        #the character used as a delimiter in the native property name\n        [string]$Delimiter = \"_\"\n        )\n\n    #split on the underscore delimiter\n    $split = $name -split $Delimiter\n\n    #capitalize the first letter of each item in the array\n    for ($i=0;$i -lt $split.count;$i++) {\n        $split[$i] = \"{0}{1}\" -f $split[$i][0].ToString().ToUpper(),$split[$i].Substring(1)\n    }\n\n    #rejoin with no spaces and write the result to the pipeline\n    $split -join \"\"\n}<\/code><\/pre>\n\n\n\n<p>I wrote the function to be flexible and not assuming that all property names will be using the underscore.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"299\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/convert-propertyname-1024x299.png\" alt=\"converting a raw property name with PowerShell\" class=\"wp-image-7941\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/convert-propertyname-1024x299.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/convert-propertyname-300x88.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/convert-propertyname-768x224.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/convert-propertyname-850x248.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/convert-propertyname.png 1468w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Building an Object<\/h2>\n\n\n\n<p>With this function in mind, I can write a simple piece of PowerShell code to create a new custom object.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$me.psobject.properties | Foreach-object -Begin {\n    $newObj = [ordered]@{\n        PSTypeName = \"BlueBirdUser\"\n    }\n} -process {\n    $newProp = Convert-PropertyName $_.Name\n    $newObj.Add($newProp,$_.value)\n} -end {\n    #write the result as a custom object\n   [PSCustomObject]$newObj\n}<\/code><\/pre>\n\n\n\n<p>The code is creating an ordered hashtable then adds an entry for each converted property name and the corresponding value from the psobject. At the end of ForEach-Object, I write an actual object to the pipeline.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"381\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/converted-properties-1024x381.png\" alt=\"\" class=\"wp-image-7942\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/converted-properties-1024x381.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/converted-properties-300x112.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/converted-properties-768x286.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/converted-properties-1536x571.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/converted-properties-850x316.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/converted-properties.png 1804w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>I could take this code and build tooling around the core API code that now writes a \"better\" PowerShell object to the pipeline. There are still potential issues with property values. For example, CreatedAt is a string and not a datetime value. That can be addressed later.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Update-TypeData<\/h2>\n\n\n\n<p>One last task you might want to undertake is to refine how PowerShell uses your new custom object. Right now, my code writes an object with all properties. While that could be useful, it may be that by default the user only needs to see a subset of properties. Or you might want to fine-tune some of the property names. For example, my output now has a property called <em>StatusesCount<\/em>. What that really means is the number of tweets. It would be more user-friendly to change that property name.<\/p>\n\n\n\n<p>All of this is where the Update-TypeData cmdlet comes into the picture. In order to use this cmdlet, your object must have a defined and unique type name. None of this will work with a generic pscustomobject. In my code, you may have noticed this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">  PSTypeName = \"BlueBirdUser\"<\/code><\/pre>\n\n\n\n<p>If I run my code and pipe to Get-Member, I'll see a TypeName of BlueBirdUser. This means I can use Update-TypeData. I'm trusting you will read full help and examples.<\/p>\n\n\n\n<p>First, I want to create some property aliases. PowerShell does this all the time for you.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Update-TypeData -TypeName BlueBirdUser -MemberType AliasProperty -MemberName Followers -Value FollowersCount -force\nUpdate-TypeData -TypeName BlueBirdUser -MemberType AliasProperty -MemberName Tweets -Value StatusesCount -Force<\/code><\/pre>\n\n\n\n<p>The other step is that I want to define a default set of properties so that when my command is run, and the custom object written to the pipeline, unless the user asks for anything else, it will display a default property set.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Update-TypeData -TypeName BlueBirdUser -DefaultDisplayPropertySet \"Name\",\"ScreenName\",\"ID\",\"Location\",\"Description\",\"Followers\",\"Tweets\" -force<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"217\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount-1024x217.png\" alt=\"\" class=\"wp-image-7943\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount-1024x217.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount-300x64.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount-768x163.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount-1536x325.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount-2048x434.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount-850x180.png 850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>If you were building a module, you might have Convert-Property as a private function, and a command like this as a public function.<\/p>\n\n\n\n<pre class=\"wp-block-code\" title=\"Get-TwitterAccount\"><code lang=\"powershell\" class=\"language-powershell\">Function Get-TwitterAccount {\n    [cmdletbinding()]\n\n    Param([string]$Username = \"jeffhicks\")\n\n    #Get-TwitterUser could be any REST API related code that creates an objecgt\n    $TwitterUser = Get-TwitterUser -ScreenName $UserName\n\n    $TwitterUser.psobject.properties | ForEach-Object -Begin {\n        $newObj = [ordered]@{\n            PSTypeName = \"BlueBirdUser\"\n        }\n    } -Process {\n        $newProp = Convert-PropertyName $_.Name\n        $newObj.Add($newProp, $_.value)\n    } -End {\n        #write the result as a custom object\n        [PSCustomObject]$newObj\n    }\n\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"426\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount2-1024x426.png\" alt=\"custom PowerShell objects\" class=\"wp-image-7944\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount2-1024x426.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount2-300x125.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount2-768x320.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount2-1536x640.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount2-2048x853.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/Get-TwitterAccount2-850x354.png 850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now I have a PowerShell tool that writes proper, well-structured objects to the pipeline that I can use like any other command.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The last week or so I&#8217;ve been playing with a new PowerShell project from Dave Carroll for using Twitter from a PowerShell prompt. The module is called BluebirdPS and you can install it from the PowerShell Gallery. The module is very much still in its early stages but is functional and intriguing. The reason you&#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 on the blog: Creating PowerShell Property Names","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":[540],"class_list":["post-7937","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Creating PowerShell Property Names &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"If you are creating REST based PowerShell tools, you might need to reformat property names to make them more PowerShell friendly.\" \/>\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\/7937\/creating-powershell-property-names\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating PowerShell Property Names &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"If you are creating REST based PowerShell tools, you might need to reformat property names to make them more PowerShell friendly.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-08T17:03:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-08T17:03:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/get-twitteruser-1024x405.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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7937\\\/creating-powershell-property-names\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7937\\\/creating-powershell-property-names\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Creating PowerShell Property Names\",\"datePublished\":\"2020-12-08T17:03:24+00:00\",\"dateModified\":\"2020-12-08T17:03:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7937\\\/creating-powershell-property-names\\\/\"},\"wordCount\":774,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7937\\\/creating-powershell-property-names\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/get-twitteruser-1024x405.png\",\"keywords\":[\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7937\\\/creating-powershell-property-names\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7937\\\/creating-powershell-property-names\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7937\\\/creating-powershell-property-names\\\/\",\"name\":\"Creating PowerShell Property Names &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7937\\\/creating-powershell-property-names\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7937\\\/creating-powershell-property-names\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/get-twitteruser-1024x405.png\",\"datePublished\":\"2020-12-08T17:03:24+00:00\",\"dateModified\":\"2020-12-08T17:03:30+00:00\",\"description\":\"If you are creating REST based PowerShell tools, you might need to reformat property names to make them more PowerShell friendly.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7937\\\/creating-powershell-property-names\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7937\\\/creating-powershell-property-names\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7937\\\/creating-powershell-property-names\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/get-twitteruser.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/get-twitteruser.png\",\"width\":2198,\"height\":869},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7937\\\/creating-powershell-property-names\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating PowerShell Property Names\"}]},{\"@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":"Creating PowerShell Property Names &#8226; The Lonely Administrator","description":"If you are creating REST based PowerShell tools, you might need to reformat property names to make them more PowerShell friendly.","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\/7937\/creating-powershell-property-names\/","og_locale":"en_US","og_type":"article","og_title":"Creating PowerShell Property Names &#8226; The Lonely Administrator","og_description":"If you are creating REST based PowerShell tools, you might need to reformat property names to make them more PowerShell friendly.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/","og_site_name":"The Lonely Administrator","article_published_time":"2020-12-08T17:03:24+00:00","article_modified_time":"2020-12-08T17:03:30+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/get-twitteruser-1024x405.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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Creating PowerShell Property Names","datePublished":"2020-12-08T17:03:24+00:00","dateModified":"2020-12-08T17:03:30+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/"},"wordCount":774,"commentCount":1,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/get-twitteruser-1024x405.png","keywords":["Scripting"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/","name":"Creating PowerShell Property Names &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/get-twitteruser-1024x405.png","datePublished":"2020-12-08T17:03:24+00:00","dateModified":"2020-12-08T17:03:30+00:00","description":"If you are creating REST based PowerShell tools, you might need to reformat property names to make them more PowerShell friendly.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/get-twitteruser.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/get-twitteruser.png","width":2198,"height":869},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7937\/creating-powershell-property-names\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Creating PowerShell Property Names"}]},{"@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":8787,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8787\/prerelease-of-psfunctiontools-for-powershell\/","url_meta":{"origin":7937,"position":0},"title":"Prerelease of PSFunctionTools for PowerShell","author":"Jeffery Hicks","date":"January 13, 2022","format":false,"excerpt":"At the end of last year wrote a series of blog posts describing tools and techniques for working with PowerShell scripts and functions. My goal was to build a framework of tools that I could use to automate PowerShell scripting work, such as creating a new module from a group\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\/psfunctiontools-commands.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/psfunctiontools-commands.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/psfunctiontools-commands.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/psfunctiontools-commands.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/psfunctiontools-commands.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/psfunctiontools-commands.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":7468,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7468\/powershell-7-scripting-with-the-powershell-ise\/","url_meta":{"origin":7937,"position":1},"title":"PowerShell 7 Scripting with the PowerShell ISE","author":"Jeffery Hicks","date":"May 11, 2020","format":false,"excerpt":"By now, everyone should have gotten the memo that with the move to PowerShell 7, the PowerShell ISE should be considered deprecated. When it comes to PowerShell script and module development for PowerShell 7, the recommended tool is Visual Studio Code. It is free and offers so much more than\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\/2020\/05\/ise-ps7.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":2125,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2125\/powershell-ise-addon-modulemenu\/","url_meta":{"origin":7937,"position":2},"title":"PowerShell ISE AddOn ModuleMenu","author":"Jeffery Hicks","date":"February 24, 2012","format":false,"excerpt":"Recently I did an online presentation on ISE Addons. As I was preparing for the talk one thing led to another, as they usually do when I'm working in PowerShell, and before I knew it I had a new add-on for the PowerShell ISE. This addon creates a menu for\u2026","rel":"","context":"In &quot;PowerShell ISE&quot;","block_context":{"text":"PowerShell ISE","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/02\/modulemenu-300x136.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":6142,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6142\/join-me-for-a-2-day-powershell-scripting-workshop\/","url_meta":{"origin":7937,"position":3},"title":"Join Me for a 2 Day PowerShell Scripting Workshop","author":"Jeffery Hicks","date":"November 12, 2018","format":false,"excerpt":"I am very happy to announce a 2 day public PowerShell learning event. In association with the fine people behind the Techmentor conference, I will be presenting a 2 day PowerShell Scripting workshop in Dallas, TX on February 4-5, 2019. There is an option to attend virtually, but you'll really\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"announcer-blue","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/announcer-blue_thumb.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3722,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3722\/reflections-on-the-powershell-scripting-games\/","url_meta":{"origin":7937,"position":4},"title":"Reflections on the PowerShell Scripting Games","author":"Jeffery Hicks","date":"February 26, 2014","format":false,"excerpt":"During the most recent PowerShell Scripting Games, I was fortunate enough to be one of the judges. Now that the games have concluded I thought I'd share my reflections on the entries. Naturally these are merely my opinions but they are drawn from years of experience with PowerShell and almost\u2026","rel":"","context":"In &quot;Best Practices&quot;","block_context":{"text":"Best Practices","link":"https:\/\/jdhitsolutions.com\/blog\/category\/best-practices\/"},"img":{"alt_text":"talkbubble","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":5833,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5833\/new-powershell-projects-published\/","url_meta":{"origin":7937,"position":5},"title":"New PowerShell Projects Published","author":"Jeffery Hicks","date":"December 18, 2017","format":false,"excerpt":"Last week I published a few of the recent PowerShell modules I've been working on to the PowerShell Gallery. These projects had been in a beta phase while I worked out some last minute features. I was also waiting to see if there were any issues reported by you that\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/12\/image_thumb-6.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/12\/image_thumb-6.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/12\/image_thumb-6.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7937","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=7937"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7937\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=7937"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=7937"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=7937"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}