{"id":157,"date":"2007-06-20T00:14:01","date_gmt":"2007-06-20T08:14:01","guid":{"rendered":"http:\/\/testblog.sapien.com\/index.php\/2007\/06\/20\/under-the-hood-extensions\/"},"modified":"2007-06-20T00:14:01","modified_gmt":"2007-06-20T08:14:01","slug":"under-the-hood-extensions","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2007\/06\/20\/under-the-hood-extensions\/","title":{"rendered":"Under The Hood Extensions"},"content":{"rendered":"<p>Thanks to all who attended the Technet webcast on PowerShell extensions. I&#8217;ve corrected the slide with the syntax for expressions. It will be included in the final PowerPoint file you can download from Microsoft.&nbsp; <\/p>\n<p>Here are some clearer examples on using expressions:<\/p>\n<p><font face=\"Lucida Console\"><font color=\"#008000\" style=\"color: rgb(0, 128, 0);\">#another example with Get-Process<br \/><\/font><font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">Get-Process<\/font> | <font color=\"#800000\" style=\"color: rgb(128, 0, 0);\">select<\/font> Name,ID,<font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">@{<\/font>Name=&#8221;<font color=\"#800000\" style=\"color: rgb(128, 0, 0);\">Working Set<\/font>&#8221;<font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">;<\/font>`<br \/>Expression=<font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">{<\/font>&#8221;{<font color=\"#800000\" style=\"color: rgb(128, 0, 0);\">0:N2<\/font>}&#8221; -f (<font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">$_.<\/font>Workingset\/1mb<font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">)}}<\/font> <\/font> <\/p>\n<p><font face=\"Lucida Console\"><font color=\"#008000\" style=\"color: rgb(0, 128, 0);\">#example with Format-Table<br \/><\/font><font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">Get-Process<\/font> |<font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">Format-Table<\/font> Name,ID,StartTime,<font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">@{<\/font>Label=&#8221;<font color=\"#800000\" style=\"color: rgb(128, 0, 0);\">Age(min)<\/font>&#8221;<font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">;<\/font>`<br \/>Expression=<font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">{(Get-Date<\/font>).Subtract(<font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">$_.<\/font>startTime).Minutes<font color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">}}<\/font> -auto<\/font> <\/p>\n<p>The main difference between what you use for Select vs Format is that Select uses &#8216;Name&#8217; and Format uses &#8216;Label&#8217;. <\/p>\n<p>Attached you will find a zip file with&nbsp;my .ps1xml files for custom type and view extensions.&nbsp; You&#8217;ll need to save them locally and use the appropriate Update cmdlet before you can use them.<\/p>\n<p>I&#8217;ve divided up the content into separate ps1 files.&nbsp; You should be able to run them as scripts or simply copy and paste the snippets into PowerShell. If you have any follow-up questions or comments, please post them in the PowerShell forum at <a href=\"http:\/\/www.scriptinganswers.com\/\">ScriptingAnswers.com.<\/a>&nbsp; It is free, although you need to register. <\/p>\n<div class=\"wlWriterSmartContent\" id=\"0767317B-992E-4b12-91E0-4F059A8CECA8:6ea9434d-1e44-422d-ad5a-2ddb0ac858c2\" style=\"margin: 0px; padding: 0px; display: inline;\"><span class=\"sizeLess20\">del.icio.us Tags: <a href=\"http:\/\/del.icio.us\/popular\/PowerShell\" rel=\"tag\">PowerShell<\/a>, <a href=\"http:\/\/del.icio.us\/popular\/ps1xml\" rel=\"tag\">ps1xml<\/a>, <a href=\"http:\/\/del.icio.us\/popular\/TypeExtension\" rel=\"tag\">TypeExtension<\/a>, <a href=\"http:\/\/del.icio.us\/popular\/Scripting\" rel=\"tag\">Scripting<\/a>, <a href=\"http:\/\/del.icio.us\/popular\/Technet\" rel=\"tag\">Technet<\/a>, <a href=\"http:\/\/del.icio.us\/popular\/Add-Member\" rel=\"tag\">Add-Member<\/a><\/span><\/div>\n<p><span class=\"sizeLess20\"><br \/><\/span> <\/p>\n<div class=\"wlWriterSmartContent\" id=\"0767317B-992E-4b12-91E0-4F059A8CECA8:4622f2ab-daf9-42d9-81d0-26bbdbb38136\" style=\"margin: 0px; padding: 0px; display: inline;\"><span class=\"sizeLess20\">Technorati Tags: <a href=\"http:\/\/technorati.com\/tags\/PowerShell\" rel=\"tag\">PowerShell<\/a>, <a href=\"http:\/\/technorati.com\/tags\/ps1xml\" rel=\"tag\">ps1xml<\/a>, <a href=\"http:\/\/technorati.com\/tags\/TypeExtension\" rel=\"tag\">TypeExtension<\/a>, <a href=\"http:\/\/technorati.com\/tags\/Scripting\" rel=\"tag\">Scripting<\/a>, <a href=\"http:\/\/technorati.com\/tags\/Technet\" rel=\"tag\">Technet<\/a>, <a href=\"http:\/\/technorati.com\/tags\/Add-Member\" rel=\"tag\">Add-Member<\/a><\/span><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Thanks to all who attended the Technet webcast on PowerShell extensions. I&#8217;ve corrected the slide with the syntax for expressions. It will be included in the final PowerPoint file you can download from Microsoft.&nbsp; Here are some clearer examples on using expressions: #another example with Get-ProcessGet-Process | select Name,ID,@{Name=&#8221;Working Set&#8221;;`Expression={&#8221;{0:N2}&#8221; -f ($_.Workingset\/1mb)}} #example with Format-TableGet-Process [&hellip;]<\/p>\n","protected":false},"author":3,"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,"footnotes":""},"categories":[25],"tags":[],"class_list":["post-157","post","type-post","status-publish","format-standard","hentry","category-windows-powershell"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=157"}],"version-history":[{"count":0,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/157\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}