{"id":3757,"date":"2014-03-25T12:11:22","date_gmt":"2014-03-25T16:11:22","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=3757"},"modified":"2014-03-28T13:45:35","modified_gmt":"2014-03-28T17:45:35","slug":"convert-a-string-to-a-powershell-property-name","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/","title":{"rendered":"Convert a String to a PowerShell Property Name"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-1688\" alt=\"talkbubble\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble.png\" width=\"198\" height=\"208\" \/><\/a>Over the last few years I've written and presented a bit on the idea of turning command line tools into PowerShell tools. We have a lot of great CLI based tools that are still worth using. What I've done is come up with tools and techniques for turning their output into an object that can be used in the PowerShell pipeline. Often all I need to do is parse and clean up command line output. But one thing that has always nagged me is what to use for property names.<\/p>\n<p>For example, I can pretty easily turn output from the ARP.EXE command into objects. Here's what I start with.<br \/>\n<a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/03\/arp-a.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-3758\" alt=\"arp-a\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/03\/arp-a-300x161.png\" width=\"300\" height=\"161\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/03\/arp-a-300x161.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/03\/arp-a.png 513w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>What I want to do is take the column headings and turn them into properties. The problem is I don't like spaces in property names. Plus, I would need to know in advance the command line heading so I could use something like a custom hashtable to rename. I was after something a bit more convenient and something that would work with almost any command line output, although I think tabular output works best. Thus I came up with a short function I call Convert-StringProperty.<\/p>\n<pre class=\"lang:ps decode:true crayon-selected\">Function Convert-StringProperty {\r\n\r\n&lt;#\r\n.Synopsis\r\nConvert strings to proper case property names.\r\n.Description\r\nThis function will take strings like principal_id and convert it into a form\r\nmore suitable for a property name, ie PrincipalID. If the text doesn't contain\r\nthe delimiter, which by default is a single space, then the first character will\r\nbe set to upper case. Otherwise, the string is is split on the delimiter, each\r\nfirst character is set to upper case and then everything joined back together.\r\n\r\n.Example\r\nPS C:\\&gt; Convert-StringProperty principal_id\r\nPrincipalId\r\n.Example\r\nPS C:\\&gt; $raw = arp -g | select -Skip 2\r\n\r\nThis command will get ARP data. It can then be processed using this function:\r\n\r\nPS C:\\&gt; [regex]$rx=\"\\s{2,}\"\r\nPS C:\\&gt; $properties = $rx.Split($raw[0].trim()) | Convert-StringProperty  \r\nPS C:\\&gt; for ($i=1;$i -lt $raw.count; $i++) {\r\n  $splitData = $rx.split($raw[$i].Trim())\r\n  #create an object for each entry\r\n  $hash = [ordered]@{}\r\n  for ($j=0;$j -lt $properties.count;$j++) {\r\n    $hash.Add($properties[$j],$splitData[$j])\r\n  } \r\n  [pscustomobject]$hash\r\n}\r\n\r\nInternetAddress                     PhysicalAddress                        Type                                       \r\n---------------                     ---------------                        ----                                       \r\n172.16.10.1                         00-13-d3-66-50-4b                      dynamic                                    \r\n172.16.10.100                       00-0d-a2-01-07-5d                      dynamic                                    \r\n172.16.10.101                       2c-76-8a-3d-11-30                      dynamic                                    \r\n172.16.10.199                       00-0a-cd-25-28-99                      dynamic                                    \r\n172.16.10.254                       20-4e-7f-b5-0f-1a                      dynamic                                    \r\n172.16.100.1                        c4-3d-c7-48-16-ee                      dynamic                                    \r\n172.16.255.255                      ff-ff-ff-ff-ff-ff                      static                                     \r\n224.0.0.22                          01-00-5e-00-00-16                      static                                     \r\n224.0.0.251                         01-00-5e-00-00-fb                      static                                     \r\n224.0.0.252                         01-00-5e-00-00-fc                      static                                     \r\n239.255.255.250                     01-00-5e-7f-ff-fa                      static                                     \r\n255.255.255.255                     ff-ff-ff-ff-ff-ff                      static\r\n.Notes\r\nLast Updated: 3\/27\/2014\r\nVersion     : 0.9.6\r\n\r\nLearn more:\r\n PowerShell in Depth: An Administrator's Guide\r\n PowerShell Deep Dives \r\n Learn PowerShell 3 in a Month of Lunches \r\n Learn PowerShell Toolmaking in a Month of Lunches \r\n\r\n   ****************************************************************\r\n   * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *\r\n   * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *\r\n   * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *\r\n   * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING.             *\r\n   ****************************************************************\r\n\r\n.Link\r\nhttp:\/\/jdhitsolutions.com\/blog\/2014\/03\/convert-a-string-to-a-powershell-property-name\r\n#&gt;\r\n\r\n[cmdletbinding()]\r\nParam(\r\n[Parameter(Position=0,Mandatory=$True,\r\nHelpMessage=\"Enter a string to convert\",\r\nValueFromPipeline=$True,\r\nValueFromPipelineByPropertyName=$True)]\r\n[ValidateNotNullorEmpty()]\r\n[Alias(\"name\")]\r\n[string]$Text,\r\n\r\n[ValidateNotNullorEmpty()]\r\n[string]$Delimiter = \" \"\r\n\r\n)\r\n\r\nBegin {\r\n    Write-Verbose -Message \"Starting $($MyInvocation.Mycommand)\"  \r\n    Write-Verbose \"Using delimiter: $Delimiter\"\r\n\r\n    #define a regular expression pattern\r\n    [regex]$rx = \"[^$Delimiter]+\"\r\n\r\n} #begin\r\n\r\nProcess {\r\n    Write-Verbose \"Converting $Text\"\r\n    #initialize the output string for the new property name\r\n    [string]$Output=\"\"\r\n\r\n    #find each word\r\n    $rx.Matches($text) | foreach {\r\n\r\n      #capitalize the first letter of each word\r\n      $value = \"{0}{1}\" -f $_.value[0].tostring().ToUpper(),$_.value.tostring().substring(1).ToLower()\r\n\r\n      #and add to output stipping off any extra non word characters\r\n      $output+=  $Value -replace \"\\W+\",\"\"\r\n\r\n    } #foreach\r\n\r\n    #send the new string to the pipeline\r\n    $Output\r\n    $counter++\r\n} # process\r\n\r\nEnd {\r\n    Write-Verbose -Message \"Ending $($MyInvocation.Mycommand)\"\r\n} #end\r\n\r\n} #end function<\/pre>\n<p>Here's how it works. I'll take the raw ARP output and skip the first couple of lines.<\/p>\n<pre class=\"lang:ps decode:true\">$raw = arp -g | select -Skip 2<\/pre>\n<p>The $raw variable has the data I want to turn into objects.<\/p>\n<pre class=\"lang:batch decode:true\">  \r\nInternet Address      Physical Address      Type\r\n  172.16.10.1           00-13-d3-66-50-4b     dynamic\r\n  172.16.10.100         00-0d-a2-01-07-5d     dynamic\r\n  172.16.10.101         2c-76-8a-3d-11-30     dynamic\r\n  172.16.10.199         00-0a-cd-25-28-99     dynamic\r\n  172.16.10.254         20-4e-7f-b5-0f-1a     dynamic\r\n  172.16.30.212         94-de-80-84-8d-4d     dynamic\r\n  172.16.100.1          c4-3d-c7-48-16-ee     dynamic\r\n  172.16.255.255        ff-ff-ff-ff-ff-ff     static\r\n  224.0.0.22            01-00-5e-00-00-16     static\r\n  224.0.0.251           01-00-5e-00-00-fb     static\r\n  224.0.0.252           01-00-5e-00-00-fc     static\r\n  239.255.255.246       01-00-5e-7f-ff-f6     static\r\n  239.255.255.250       01-00-5e-7f-ff-fa     static\r\n  255.255.255.255       ff-ff-ff-ff-ff-ff     static<\/pre>\n<p>The first line contains the property names but I want them without the spaces. As a separate step, outside of the function, I need to split the first line. I'm going to do that with a regular expression pattern that matches 2 or more white spaces.<\/p>\n<pre class=\"lang:ps decode:true\">[regex]$rx=\"\\s{2,}\"\r\n$properties = $rx.Split($raw[0].trim()) | Convert-StringProperty<\/pre>\n<p>I can take the first line, item [0], remove leading and trailing spaces and split it. This will give me three strings: Internet Address, Physical Address, and Type. Each of these is then piped to my Convert-StringProperty.<\/p>\n<p>The function will look at each string and split it again based on a delimiter, which by default is a space. But you can specify something different if you run into CLI names like INTERNET_ADDRESS. Each word is then processed with a capital first letter. The end result is camel case so \"Internet Address\" becomes \"InternetAddress\".<\/p>\n<p>Once I know what my property names will be, I can continue parsing the command line output and create a custom object.<\/p>\n<pre class=\"lang:ps decode:true\">for ($i=1;$i -lt $raw.count; $i++) {\r\n  $splitData = $rx.split($raw[$i].Trim())\r\n  #create an object for each entry\r\n  $hash = [ordered]@{}\r\n  for ($j=0;$j -lt $properties.count;$j++) {\r\n    $hash.Add($properties[$j],$splitData[$j])\r\n  } \r\n  [pscustomobject]$hash\r\n}<\/pre>\n<p>You still need to come up with code to process your command line tool, but you can use this function to define proper PowerShell properties. Here's one more example.<\/p>\n<pre class=\"lang:ps decode:true\">$raw = qprocess\r\n$properties = $raw[0] -split \"\\s{2,}\" | Convert-StringProperty\r\n$raw | select -Skip 1 | foreach {\r\n #split each line\r\n $data = $_ -split \"\\s{2,}\"\r\n $hash=[ordered]@{}\r\n for ($i=0;$i -lt $properties.count;$i++) {\r\n   #strip off any non word characters\r\n   $hash.Add($properties[$i],($data[$i] -replace '\\W+',''))\r\n }\r\n [pscustomobject]$hash\r\n}<\/pre>\n<p>This takes command output like this:<\/p>\n<pre class=\"lang:batch decode:true\"> USERNAME              SESSIONNAME         ID    PID  IMAGE\r\n jeff                  services             0   1920  sqlservr.exe\r\n&gt;jeff                  console              1   3312  taskhostex.exe\r\n&gt;jeff                  console              1   3320  ipoint.exe\r\n&gt;jeff                  console              1   3328  itype.exe<\/pre>\n<p>And turns it into PowerShell output like this:<\/p>\n<pre class=\"lang:batch decode:true\">Username    : jeff\r\nSessionname : services\r\nId          : 0\r\nPid         : 1920\r\nImage       : sqlservrexe\r\n\r\nUsername    : jeff\r\nSessionname : console\r\nId          : 1\r\nPid         : 3312\r\nImage       : taskhostexexe\r\n\r\nUsername    : jeff\r\nSessionname : console\r\nId          : 1\r\nPid         : 3320\r\nImage       : ipointexe<\/pre>\n<p>In another article I'll share with you another tool that takes advantage of this function. Enjoy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over the last few years I&#8217;ve written and presented a bit on the idea of turning command line tools into PowerShell tools. We have a lot of great CLI based tools that are still worth using. What I&#8217;ve done is come up with tools and techniques for turning their output into an object that can&#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 blog meat: Convert a String to a #PowerShell Property Name http:\/\/wp.me\/p1nF6U-YB","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":[72,4,8],"tags":[20,534,250,540],"class_list":["post-3757","post","type-post","status-publish","format-standard","hentry","category-commandline","category-powershell","category-scripting","tag-cli","tag-powershell","tag-regular-expressions","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Convert a String to a PowerShell Property Name &#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\/3757\/convert-a-string-to-a-powershell-property-name\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Convert a String to a PowerShell Property Name &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Over the last few years I&#039;ve written and presented a bit on the idea of turning command line tools into PowerShell tools. We have a lot of great CLI based tools that are still worth using. What I&#039;ve done is come up with tools and techniques for turning their output into an object that can...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2014-03-25T16:11:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-03-28T17:45:35+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble.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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3757\\\/convert-a-string-to-a-powershell-property-name\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3757\\\/convert-a-string-to-a-powershell-property-name\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Convert a String to a PowerShell Property Name\",\"datePublished\":\"2014-03-25T16:11:22+00:00\",\"dateModified\":\"2014-03-28T17:45:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3757\\\/convert-a-string-to-a-powershell-property-name\\\/\"},\"wordCount\":460,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3757\\\/convert-a-string-to-a-powershell-property-name\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2011\\\/10\\\/talkbubble.png\",\"keywords\":[\"CLI\",\"PowerShell\",\"Regular Expressions\",\"Scripting\"],\"articleSection\":[\"CommandLine\",\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3757\\\/convert-a-string-to-a-powershell-property-name\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3757\\\/convert-a-string-to-a-powershell-property-name\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3757\\\/convert-a-string-to-a-powershell-property-name\\\/\",\"name\":\"Convert a String to a PowerShell Property Name &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3757\\\/convert-a-string-to-a-powershell-property-name\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3757\\\/convert-a-string-to-a-powershell-property-name\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2011\\\/10\\\/talkbubble.png\",\"datePublished\":\"2014-03-25T16:11:22+00:00\",\"dateModified\":\"2014-03-28T17:45:35+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3757\\\/convert-a-string-to-a-powershell-property-name\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3757\\\/convert-a-string-to-a-powershell-property-name\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3757\\\/convert-a-string-to-a-powershell-property-name\\\/#primaryimage\",\"url\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2011\\\/10\\\/talkbubble.png\",\"contentUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2011\\\/10\\\/talkbubble.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3757\\\/convert-a-string-to-a-powershell-property-name\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"CommandLine\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/commandline\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Convert a String to a PowerShell Property Name\"}]},{\"@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":"Convert a String to a PowerShell Property Name &#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\/3757\/convert-a-string-to-a-powershell-property-name\/","og_locale":"en_US","og_type":"article","og_title":"Convert a String to a PowerShell Property Name &#8226; The Lonely Administrator","og_description":"Over the last few years I've written and presented a bit on the idea of turning command line tools into PowerShell tools. We have a lot of great CLI based tools that are still worth using. What I've done is come up with tools and techniques for turning their output into an object that can...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/","og_site_name":"The Lonely Administrator","article_published_time":"2014-03-25T16:11:22+00:00","article_modified_time":"2014-03-28T17:45:35+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble.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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Convert a String to a PowerShell Property Name","datePublished":"2014-03-25T16:11:22+00:00","dateModified":"2014-03-28T17:45:35+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/"},"wordCount":460,"commentCount":4,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble.png","keywords":["CLI","PowerShell","Regular Expressions","Scripting"],"articleSection":["CommandLine","PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/","name":"Convert a String to a PowerShell Property Name &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble.png","datePublished":"2014-03-25T16:11:22+00:00","dateModified":"2014-03-28T17:45:35+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/#primaryimage","url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble.png","contentUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble.png"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3757\/convert-a-string-to-a-powershell-property-name\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"CommandLine","item":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},{"@type":"ListItem","position":2,"name":"Convert a String to a PowerShell Property Name"}]},{"@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":3101,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3101\/turning-cli-tools-into-powershell-tools\/","url_meta":{"origin":3757,"position":0},"title":"Turning CLI Tools into PowerShell Tools","author":"Jeffery Hicks","date":"June 12, 2013","format":false,"excerpt":"Last night I gave a presentation for the Mississippi PowerShell User Group. My talk was based on the chapter I contributed to the forthcoming PowerShell Deep Dives book. In the chapter I explore different techniques for turning command line tools into PowerShell tools. My presentation demonstrated those techniques in action.\u2026","rel":"","context":"In &quot;CommandLine&quot;","block_context":{"text":"CommandLine","link":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},"img":{"alt_text":"talkbubble","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1708,"url":"https:\/\/jdhitsolutions.com\/blog\/commandline\/1708\/turning-cli-tools-into-powershell-tools-deep-dive-demos\/","url_meta":{"origin":3757,"position":1},"title":"Turning CLI Tools into PowerShell Tools Deep Dive Demos","author":"Jeffery Hicks","date":"October 24, 2011","format":false,"excerpt":"Last week I did a presentation at the PowerShell Deep Dive in Frankfurt about turning command line tools into PowerShell tools. A video recording should be posted later. But in the meantime, here is a copy of my slide deck, in PDF and a zip file with my demos and\u2026","rel":"","context":"In &quot;CommandLine&quot;","block_context":{"text":"CommandLine","link":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/nbtstat-n-300x158.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1636,"url":"https:\/\/jdhitsolutions.com\/blog\/conferences\/1636\/powershell-deep-dive-europe\/","url_meta":{"origin":3757,"position":2},"title":"PowerShell Deep Dive Europe","author":"Jeffery Hicks","date":"August 29, 2011","format":false,"excerpt":"I'm happy to report that I will be presenting a session at the PowerShell Deep Dive in Frankfurt this October as part of The Experts Conference. The conference in Las Vegas this past April was amazing, intense and the most fun I think I've ever had. If you can make\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1716,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1716\/convert-text-to-object\/","url_meta":{"origin":3757,"position":3},"title":"Convert Text to Object","author":"Jeffery Hicks","date":"October 25, 2011","format":false,"excerpt":"Today I have another tool in my new battle regarding turning command line tools into PowerShell tools. The bottom line is we want to have objects written to the pipeline. At the PowerShell Deep Dive in Frankfurt there was a suggestion about providing tools to help with the transformation from\u2026","rel":"","context":"In &quot;CommandLine&quot;","block_context":{"text":"CommandLine","link":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":525,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/525\/join-me-at-techmentor-orlando\/","url_meta":{"origin":3757,"position":4},"title":"Join Me at Techmentor Orlando","author":"Jeffery Hicks","date":"December 7, 2009","format":false,"excerpt":"I will be presenting several sessions at Techmentor in Orlando, FL March 8-12, 2010. I will be doing the following sessions: Take Back your File Server (learn about Server 2008 file management features) Top 10 Non-PowerShell CLI Tools you MUST Know (learn about other command line tools that can get\u2026","rel":"","context":"In &quot;CommandLine&quot;","block_context":{"text":"CommandLine","link":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7648,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7648\/updated-powershell-tools\/","url_meta":{"origin":3757,"position":5},"title":"Updated PowerShell Tools","author":"Jeffery Hicks","date":"August 14, 2020","format":false,"excerpt":"I've released a new version of my popular PSScriptTools module, which you can install from the PowerShell Gallery. The module is collection of commands and tools that I use in my scripting and day-to-day work at a PowerShell console. Many of the commands run in Windows PowerShell and PowerShell 7,\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\/08\/get-myalias-2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/08\/get-myalias-2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/08\/get-myalias-2.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/08\/get-myalias-2.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/08\/get-myalias-2.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/08\/get-myalias-2.png?resize=1400%2C800&ssl=1 4x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3757","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=3757"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3757\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3757"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3757"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}