{"id":3269,"date":"2013-07-07T11:59:00","date_gmt":"2013-07-07T11:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/07\/07\/powertip-find-unique-types-with-powershell\/"},"modified":"2013-07-07T11:59:00","modified_gmt":"2013-07-07T11:59:00","slug":"powertip-find-unique-types-with-powershell","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-find-unique-types-with-powershell\/","title":{"rendered":"PowerTip: Find Unique Types with PowerShell"},"content":{"rendered":"<p><strong style=\"font-size: 12px\">Summary<\/strong><span style=\"font-size: 12px\">: Learn an easy command to help find unique types with Windows PowerShell.<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\">&nbsp;How can I filter different types of objects from a command so that I have an example of each unique type?<\/p>\n<p style=\"padding-left: 60px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\">&nbsp;If you use the&nbsp;<strong>Get-Unique<\/strong>&nbsp;cmdlet with no switched parameters, many of the objects returned are the same type (the&nbsp;<strong>DirectoryInfo<\/strong>&nbsp;objects in this example):<\/p>\n<p style=\"padding-left: 150px\">PS C:&gt; Get-ChildItem | Get-Unique<\/p>\n<p style=\"padding-left: 150px\">&nbsp;&nbsp;&nbsp; Directory: C:<\/p>\n<p style=\"padding-left: 150px\">Mode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LastWriteTime&nbsp;&nbsp;&nbsp;&nbsp; Length Name<\/p>\n<p style=\"padding-left: 150px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212; &#8212;-<\/p>\n<p style=\"padding-left: 150px\">d&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6\/17\/2013&nbsp;&nbsp; 1:00 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Afolder<\/p>\n<p style=\"padding-left: 150px\">d&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6\/17\/2013&nbsp;&nbsp; 1:00 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Bfolder<\/p>\n<p style=\"padding-left: 150px\">d-r&#8211;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6\/2\/2013&nbsp; 10:56 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data<\/p>\n<p style=\"padding-left: 150px\">d&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;3\/9\/2013&nbsp;&nbsp; 6:35 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DRIVERS<\/p>\n<p style=\"padding-left: 150px\">&lt;output truncated&gt;<\/p>\n<p style=\"padding-left: 60px\">&nbsp; If you use the&nbsp;<strong>Get-Unique<\/strong>&nbsp;cmdlet with the&nbsp;<strong>&ndash;OnType<\/strong>&nbsp;switch, only one example of each of the type of object returns (a&nbsp;<strong>FileInfo<\/strong>&nbsp;object and a&nbsp;<strong>DirectoryInfo<\/strong>&nbsp;object in this example):<\/p>\n<p style=\"padding-left: 150px\">PS C:&gt; Get-ChildItem | Get-Unique -OnType<\/p>\n<p style=\"padding-left: 150px\">&nbsp;&nbsp;&nbsp; Directory: C:<\/p>\n<p style=\"padding-left: 150px\">Mode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LastWriteTime&nbsp;&nbsp;&nbsp;&nbsp; Length Name<\/p>\n<p style=\"padding-left: 150px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212; &#8212;-<\/p>\n<p style=\"padding-left: 150px\">d&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6\/17\/2013&nbsp;&nbsp; 1:00 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Afolder<\/p>\n<p style=\"padding-left: 150px\">-a&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3\/9\/2013&nbsp;&nbsp; 7:29 PM&nbsp;&nbsp;&nbsp; 4627788 MSIInstall.log<\/p>\n<p style=\"padding-left: 120px\">&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Learn an easy command to help find unique types with Windows PowerShell. &nbsp;How can I filter different types of objects from a command so that I have an example of each unique type? &nbsp;If you use the&nbsp;Get-Unique&nbsp;cmdlet with no switched parameters, many of the objects returned are the same type (the&nbsp;DirectoryInfo&nbsp;objects in this example): [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[356,3,45],"class_list":["post-3269","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-powertip","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Learn an easy command to help find unique types with Windows PowerShell. &nbsp;How can I filter different types of objects from a command so that I have an example of each unique type? &nbsp;If you use the&nbsp;Get-Unique&nbsp;cmdlet with no switched parameters, many of the objects returned are the same type (the&nbsp;DirectoryInfo&nbsp;objects in this example): [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/3269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=3269"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/3269\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=3269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=3269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=3269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}