{"id":8215,"date":"2021-03-11T10:01:35","date_gmt":"2021-03-11T15:01:35","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=8215"},"modified":"2021-03-11T10:01:39","modified_gmt":"2021-03-11T15:01:39","slug":"powershell-property-sets-to-the-rescue","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/","title":{"rendered":"PowerShell Property Sets to the Rescue"},"content":{"rendered":"\n<p>if you are like me and spend most of your day at a PowerShell prompt, anything that simplifies that process is worth the time to learn or set up. Even though I am a decent typist, I am more than happy to find ways to type less at a PowerShell prompt.  I already take advantage of tab completion and PSReadline features. But there is always more to  be done. Here's the situation, which I think you can relate to.<\/p>\n\n\n\n<p>Let's say that I frequently run a PowerShell command like this from the console prompt.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Get-Childitem c:\\work -file | Select-Object -Property \"Name\",\"Length\",\"CreationTime\",\"LastWriteTime\" <\/code><\/pre>\n\n\n\n<p>I'm using files, but it could be any command where you repeatedly want the same collection of property names. I  could create variable for the property names.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$p = \"Name\",\"Length\",\"CreationTime\",\"LastWriteTime\"\ndir c:\\work -file | select $p <\/code><\/pre>\n\n\n\n<p>But I'd have to remember to always define that variable. I could  define this in my PowerShell profile, but there's a better way.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Property Sets<\/h2>\n\n\n\n<p>PowerShell's extensible type system (ETS) allows for something called a <em>property set<\/em>. This is a collection of properties that you can reference by a single property name. The process object from Get-Process includes a few of these by default.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/process-propertyset.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"257\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/process-propertyset-1024x257.png\" alt=\"\" class=\"wp-image-8217\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/process-propertyset-1024x257.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/process-propertyset-300x75.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/process-propertyset-768x193.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/process-propertyset-850x213.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/process-propertyset.png 1535w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>You can try it yourself.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">get-Process | Select psconfiguration<\/code><\/pre>\n\n\n\n<p>Instead of having to type the 4 property names, you only have to type one. Even less is you use tab completion! To ease my typing burden in my sample scenario, I want a property set for file objects.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">New-PSPropertySet<\/h2>\n\n\n\n<p>Now for the not-so-easy part. Creating other type extensions like an alias property is simple with Update-TypeData. But a property set can only be defined in a .ps1xml file which is then imported using Update-TypeData. Ugh. Who wants to create XML? So I \"cheated\" and wrote a command to do it for me.<\/p>\n\n\n\n<p>I have updated my <a href=\"https:\/\/github.com\/jdhitsolutions\/PSTypeExtensionTools\" target=\"_blank\" rel=\"noreferrer noopener\">PSTypeExtensionTools <\/a>module to add a new function called <a href=\"https:\/\/github.com\/jdhitsolutions\/PSTypeExtensionTools\/blob\/master\/docs\/New-PSPropertySet.md\" target=\"_blank\" rel=\"noreferrer noopener\">New-PSPropertySet<\/a>. I can use this function to easily create the .ps1xml file. You can install the PSTypeExtensionTools module from the PowerShell Gallery. You will need v1.71 or later.<\/p>\n\n\n\n<p>To create an extension, you need to know the type name. This is what you see when you pipe to Get-Member. Here's how easy it is.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">New-PSPropertySet -Typename System.IO.FileInfo -Name TimeSet -Properties \"Name\",\"Length\",\"CreationTime\",\"LastWriteTime\" -FilePath c:\\work\\file.types.ps1xml<\/code><\/pre>\n\n\n\n<p>My property set will be called TimeSet and use the specified properties.  You need to use the ps1xml file extension so that you can import it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Update-TypeData C:\\work\\file.types.ps1xml<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"280\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset-1024x280.png\" alt=\"\" class=\"wp-image-8219\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset-1024x280.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset-300x82.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset-768x210.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset-850x232.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset.png 1252w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Now I can use this property.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"552\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset2-1024x552.png\" alt=\"\" class=\"wp-image-8220\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset2-1024x552.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset2-300x162.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset2-768x414.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset2-850x459.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/timeset2.png 1281w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>As long as I am at this, I think I'll create some new type extensions with another command from the PSTypeExtensionTools module and then define a new property set.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Add-PSTypeExtension -TypeName system.io.fileinfo -MemberType AliasProperty -MemberName Size -Value Length\nAdd-PSTypeExtension -TypeName system.io.fileinfo -MemberType ScriptProperty -MemberName ModifiedAge -Value {New-TimeSpan -Start $this.lastwritetime -End (Get-Date)}\nNew-PSPropertySet -Typename system.io.fileinfo -Name Age -Properties Name,Size,LastWriteTime,ModifiedAge -Append -FilePath C:\\work\\file.types.ps1xml<\/code><\/pre>\n\n\n\n<p>I haven't loaded the new property set but I can test the properties.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions.png\"><img loading=\"lazy\" decoding=\"async\" width=\"988\" height=\"654\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions.png\" alt=\"\" class=\"wp-image-8221\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions.png 988w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions-300x199.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions-768x508.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions-850x563.png 850w\" sizes=\"auto, (max-width: 988px) 100vw, 988px\" \/><\/a><\/figure>\n\n\n\n<p>The module has mechanisms for exporting and importing type extensions using JSON or XML. But since I have a property set, I might as well include the type extensions.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Export-PSTypeExtension -TypeName system.io.fileinfo -MemberName Size,ModifiedAge -Path c:\\work\\file.types.ps1xml -append\nUpdate-TypeData C:\\work\\file.types.ps1xml<\/code><\/pre>\n\n\n\n<p>If you re-import a file that attempts to define an existing extension, PowerShell will throw an exception. There's no ability to force an update when using a .ps1xml file. But the new settings will be created.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1022\" height=\"395\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions2.png\" alt=\"\" class=\"wp-image-8222\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions2.png 1022w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions2-300x116.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions2-768x297.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/file-typeextensions2-850x329.png 850w\" sizes=\"auto, (max-width: 1022px) 100vw, 1022px\" \/><\/a><\/figure>\n\n\n\n<p>Now I can get results with the property names I want, like <em>Size<\/em>, create new properties like <em>ModifiedAge<\/em>, and reference a group of properties as a set, like <em>Age<\/em>. All I need to do is add the Update-TypeData command in my PowerShell profile script.  <\/p>\n\n\n\n<p>I hope you find this as useful as I do. Feel free to leave comments or questions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>if you are like me and spend most of your day at a PowerShell prompt, anything that simplifies that process is worth the time to learn or set up. Even though I am a decent typist, I am more than happy to find ways to type less at a PowerShell prompt. I already take advantage&#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: #PowerShell Property Sets to the Rescue","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":[499,4],"tags":[652,534,651,540],"class_list":["post-8215","post","type-post","status-publish","format-standard","hentry","category-github","category-powershell","tag-ets","tag-powershell","tag-pstypeextension","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PowerShell Property Sets to the Rescue &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"Tired of typing the the same property names over and over? Maybe you need to extend PowerShell&#039;s type system with a property set.\" \/>\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\/8215\/powershell-property-sets-to-the-rescue\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PowerShell Property Sets to the Rescue &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Tired of typing the the same property names over and over? Maybe you need to extend PowerShell&#039;s type system with a property set.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-11T15:01:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-03-11T15:01:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/process-propertyset-1024x257.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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8215\\\/powershell-property-sets-to-the-rescue\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8215\\\/powershell-property-sets-to-the-rescue\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"PowerShell Property Sets to the Rescue\",\"datePublished\":\"2021-03-11T15:01:35+00:00\",\"dateModified\":\"2021-03-11T15:01:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8215\\\/powershell-property-sets-to-the-rescue\\\/\"},\"wordCount\":568,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8215\\\/powershell-property-sets-to-the-rescue\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/process-propertyset-1024x257.png\",\"keywords\":[\"ETS\",\"PowerShell\",\"PSTypeExtension\",\"Scripting\"],\"articleSection\":[\"GitHub\",\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8215\\\/powershell-property-sets-to-the-rescue\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8215\\\/powershell-property-sets-to-the-rescue\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8215\\\/powershell-property-sets-to-the-rescue\\\/\",\"name\":\"PowerShell Property Sets to the Rescue &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8215\\\/powershell-property-sets-to-the-rescue\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8215\\\/powershell-property-sets-to-the-rescue\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/process-propertyset-1024x257.png\",\"datePublished\":\"2021-03-11T15:01:35+00:00\",\"dateModified\":\"2021-03-11T15:01:39+00:00\",\"description\":\"Tired of typing the the same property names over and over? Maybe you need to extend PowerShell's type system with a property set.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8215\\\/powershell-property-sets-to-the-rescue\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8215\\\/powershell-property-sets-to-the-rescue\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8215\\\/powershell-property-sets-to-the-rescue\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/process-propertyset.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/process-propertyset.png\",\"width\":1535,\"height\":385},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8215\\\/powershell-property-sets-to-the-rescue\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PowerShell Property Sets to the Rescue\"}]},{\"@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":"PowerShell Property Sets to the Rescue &#8226; The Lonely Administrator","description":"Tired of typing the the same property names over and over? Maybe you need to extend PowerShell's type system with a property set.","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\/8215\/powershell-property-sets-to-the-rescue\/","og_locale":"en_US","og_type":"article","og_title":"PowerShell Property Sets to the Rescue &#8226; The Lonely Administrator","og_description":"Tired of typing the the same property names over and over? Maybe you need to extend PowerShell's type system with a property set.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/","og_site_name":"The Lonely Administrator","article_published_time":"2021-03-11T15:01:35+00:00","article_modified_time":"2021-03-11T15:01:39+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/process-propertyset-1024x257.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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"PowerShell Property Sets to the Rescue","datePublished":"2021-03-11T15:01:35+00:00","dateModified":"2021-03-11T15:01:39+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/"},"wordCount":568,"commentCount":4,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/process-propertyset-1024x257.png","keywords":["ETS","PowerShell","PSTypeExtension","Scripting"],"articleSection":["GitHub","PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/","name":"PowerShell Property Sets to the Rescue &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/process-propertyset-1024x257.png","datePublished":"2021-03-11T15:01:35+00:00","dateModified":"2021-03-11T15:01:39+00:00","description":"Tired of typing the the same property names over and over? Maybe you need to extend PowerShell's type system with a property set.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/process-propertyset.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/process-propertyset.png","width":1535,"height":385},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8215\/powershell-property-sets-to-the-rescue\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"PowerShell Property Sets to the Rescue"}]},{"@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":6308,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6308\/ultimate-powershell-telemetry-prompt\/","url_meta":{"origin":8215,"position":0},"title":"The Ultimate PowerShell Telemetry Prompt","author":"Jeffery Hicks","date":"December 20, 2018","format":false,"excerpt":"Well, I knew I wouldn't be satisfied. The other day I shared a PowerShell prompt function that could display telemetry like information for a few remote servers. One of the drawbacks was the limited amount of information I could display. I've revised that function and have a new version 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\/2018\/12\/image_thumb-15.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-15.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-15.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-15.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1292,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1292\/new-comment-help\/","url_meta":{"origin":8215,"position":1},"title":"New Comment Help","author":"Jeffery Hicks","date":"March 29, 2011","format":false,"excerpt":"If you follow my blog I'm sure you noticed that I post a lot of advanced functions and scripts. While I don't expect every one to be developing advanced functions, the closer you can get the more powerful your work. With the Scripting Games approaching I thought I'd offer up\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\/2011\/03\/helpbubble.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3918,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/3918\/pimp-your-prompt\/","url_meta":{"origin":8215,"position":2},"title":"Pimp your Prompt","author":"Jeffery Hicks","date":"July 16, 2014","format":false,"excerpt":"If you are like me and live in PowerShell, then you spend a great deal of your day looking at your PowerShell prompt. That little indicator in the console and ISE that usually shows where you are. That little part of your PowerShell world is defined by a built-in function\u2026","rel":"","context":"In &quot;Powershell 3.0&quot;","block_context":{"text":"Powershell 3.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-3-0\/"},"img":{"alt_text":"bling2","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/07\/bling2-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1376,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1376\/powershell-deep-dive-treasure\/","url_meta":{"origin":8215,"position":3},"title":"PowerShell Deep Dive Treasure","author":"Jeffery Hicks","date":"April 26, 2011","format":false,"excerpt":"Without a doubt the PowerShell Deep Dive conference was one of the best meetings I've ever attended and I wanted to share one tidbit I came away with that I find immensely useful and never knew. During one of Bruce Payette's talks he tossed out, practically as an aside, a\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":6285,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6285\/more-powershell-monitoring-prompts\/","url_meta":{"origin":8215,"position":4},"title":"More PowerShell Monitoring Prompts","author":"Jeffery Hicks","date":"December 13, 2018","format":false,"excerpt":"Wow. Do you all love PowerShell prompts or what? My prompt to display up\/down information was very popular. How about a few more? As I mentioned in my previous post, performance is super critical when it comes to a PowerShell prompt function. I've experimented with a number of different techniques\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-9.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-9.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-9.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/12\/image_thumb-9.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":7149,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7149\/friday-fun-taking-a-shortcut-path-in-your-powershell-prompt\/","url_meta":{"origin":8215,"position":5},"title":"Friday Fun: Taking a Shortcut Path in Your PowerShell Prompt","author":"Jeffery Hicks","date":"January 3, 2020","format":false,"excerpt":"To kick off the new year I thought I'd take a shortcut and reclaim some wasted space in my PowerShell prompt. I know I run into this issue during classes and conferences. Perhaps you encounter it as well. You are in in the PowerShell console and have ended up in\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\/01\/image_thumb-3.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/image_thumb-3.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/image_thumb-3.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/01\/image_thumb-3.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8215","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=8215"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8215\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}