{"id":2930,"date":"2013-09-05T00:01:00","date_gmt":"2013-09-05T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/09\/05\/windows-powershell-3-0-first-steps-part-4\/"},"modified":"2013-09-05T00:01:00","modified_gmt":"2013-09-05T00:01:00","slug":"windows-powershell-3-0-first-steps-part-4","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/windows-powershell-3-0-first-steps-part-4\/","title":{"rendered":"Windows PowerShell 3.0 First Steps: Part 4"},"content":{"rendered":"<p><strong>Summary<\/strong>: Microsoft Scripting Guy, Ed Wilson, shares a portion from his popular Microsoft Press book <em>Windows PowerShell 3.0 First Steps<\/em>.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Today I want to share with you another portion from my new book, <a href=\"http:\/\/www.amazon.com\/Windows-PowerShell-3-0-First-Steps\/dp\/0735681007\/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1377624341&amp;sr=1-1&amp;keywords=powershell+3.0+first+steps\" target=\"_blank\">Windows PowerShell 3.0 First Steps<\/a>, which was recently released by Microsoft Press.<\/p>\n<p>To read the previous parts of this series, see:<\/p>\n<ul>\n<li><a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/09\/02\/windows-powershell-3-0-first-steps-part-1.aspx\" target=\"_blank\">Windows PowerShell 3.0 First Steps: Part 1<\/a><\/li>\n<li><a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/09\/02\/windows-powershell-3-0-first-steps-part-2.aspx\" target=\"_blank\">Windows PowerShell 3.0 First Steps: Part 2<\/a><\/li>\n<li><a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/09\/02\/windows-powershell-3-0-first-steps-part-3.aspx\" target=\"_blank\">Windows PowerShell 3.0 First Steps: Part 3<\/a><\/li>\n<\/ul>\n<h2>Creating a table<\/h2>\n<p>When you have between two and five properties, and you are interested in viewing in columns of data, the <strong>Format-Table<\/strong> cmdlet is the tool to use to organize your data. The typical use of <strong>Format-Table<\/strong> is to permit delving into specific information in a customizable fashion. For example, the <strong>Get-Process<\/strong> cmdlet returns a table with eight columns that contain essential process information. The <strong>Get-Process<\/strong> command and the resulting output are shown in the following image:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1205.hsg-9-5-13-1.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1205.hsg-9-5-13-1.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<h2>Choosing specific properties in a specific order<\/h2>\n<p class=\"Normalunindented\">If the eight columns of default process information meet your needs, there is no need to think about using a formatting cmdlet. However, the <strong>Process<\/strong> object that is returned by the <strong>Get-Process<\/strong> cmdlet actually contains 51 properties and seven script properties. As a result, there is much more information available than only the eight default properties. To dive into this information requires using one of the <strong>Format<\/strong> cmdlets. From the perspective of the <strong>Get-Process<\/strong> cmdlet, there are six alias properties. Alias properties are great because they can shorten the amount of typing required. The <strong>Get-Process<\/strong> alias properties are shown in the output that follows:<\/p>\n<p class=\"CodeBlock\" style=\"padding-left: 30px\">13:40 C:\\&gt; get-process | get-member -MemberType alias*<\/p>\n<p> &nbsp;&nbsp; TypeName: System.Diagnostics.Process<\/p>\n<p> Name&nbsp;&nbsp;&nbsp; MemberType&nbsp;&nbsp;&nbsp; Definition<br \/> &#8212;-&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-<br \/> Handles AliasProperty Handles = Handlecount<br \/> Name&nbsp;&nbsp;&nbsp; AliasProperty Name = ProcessName<br \/> NPM&nbsp;&nbsp;&nbsp;&nbsp; AliasProperty NPM = NonpagedSystemMemorySize<br \/> PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AliasProperty PM = PagedMemorySize<br \/> VM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AliasProperty VM = VirtualMemorySize<br \/> WS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AliasProperty WS = WorkingSet<\/p>\n<p>To use the <strong>Format-List<\/strong> cmdlet, you pipe the results from one cmdlet to the <strong>Format-List<\/strong> cmdlet and select the property names you want to display.<\/p>\n<p class=\"ListReaderaidonly\" style=\"padding-left: 30px\"><strong>Note<\/strong>&nbsp;&nbsp;The order in which the properties appear is the order in which they display in the table.<\/p>\n<p>The following command displays process information from every process on the local system. The specified properties use the alias properties created for the <strong>Get-Process<\/strong> cmdlet. The output is in the order of Name, Handles, Virtual Memory Size, and the Working Set.<\/p>\n<p class=\"CodeBlock\">Get-Process | Format-Table -Property name, handles, vm, ws<\/p>\n<p>The command to produce the formatted list of process information, and the output associated with the command, are shown in the following image:<\/p>\n<p class=\"AltText\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6825.hsg-9-5-13-2.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6825.hsg-9-5-13-2.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p class=\"Readeraidonly\" style=\"padding-left: 30px\"><strong>Note<\/strong>&nbsp;&nbsp;The <strong>Get-Process<\/strong> cmdlet has an alias of <strong>GPS<\/strong>, and the <strong>Format-Table<\/strong> cmdlet has an alias of <strong>FT<\/strong>. Therefore, the command to return a table of process information can be shortened to the following:<\/p>\n<p class=\"ReaderaidCodeBlockScreened\" style=\"padding-left: 30px\">GPS | FT name, handles, vm, ws<\/p>\n<p>Join me tomorrow when I will have another excerpt from my Windows PowerShell 3.0 First Steps book.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><strong>Ed Wilson, Microsoft Scripting Guy<\/strong>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, shares a portion from his popular Microsoft Press book Windows PowerShell 3.0 First Steps. Microsoft Scripting Guy, Ed Wilson, is here. Today I want to share with you another portion from my new book, Windows PowerShell 3.0 First Steps, which was recently released by Microsoft Press. To read the [&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":[51,3,4,45],"class_list":["post-2930","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-getting-started","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, shares a portion from his popular Microsoft Press book Windows PowerShell 3.0 First Steps. Microsoft Scripting Guy, Ed Wilson, is here. Today I want to share with you another portion from my new book, Windows PowerShell 3.0 First Steps, which was recently released by Microsoft Press. To read the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2930","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=2930"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2930\/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=2930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}