{"id":7031,"date":"2007-11-13T00:49:45","date_gmt":"2007-11-13T00:49:45","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2007\/11\/13\/name-in-get-xxx-cmdlets\/"},"modified":"2019-02-18T13:16:24","modified_gmt":"2019-02-18T20:16:24","slug":"name-in-get-xxx-cmdlets","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/name-in-get-xxx-cmdlets\/","title":{"rendered":"-Name in Get-XXX Cmdlets"},"content":{"rendered":"<p>I just saw a cool article by Don Brown who has written a set of <a href=\"http:\/\/www.microsoft.com\/technet\/technetmag\/issues\/2007\/11\/UtilitySpotlight\/?loc=en&amp;rss=http:\/\/www.microsoft.com\/technet\/technetmag\/issues\/2007\/11\/UtilitySpotlight\/?loc=en\">SMS Cmdlets for Windows PowerShell<\/a>.  These work with SMS 2003 and are well worth a look-see if you are an SMS customer.  (Btw \u2013 I wrote Get-XXX to mean GET-(any nounname) but now that I look at it, it looks like a cmdlet to get hardcore porn \u2013 YIKES!!  I can only guess at what the parameters to such a command would be. <span style=\"font-family:Wingdings\">J<\/span> )   While Don has published a relatively small set of initial cmdlets:\n<\/p>\n<ul>\n<li>Disable-SoftwareDistribution\n<\/li>\n<li>Enable-SoftwareDistribution\n<\/li>\n<li>Get-CollectionMembers\n<\/li>\n<li>Get-Collections\n<\/li>\n<li>Get-SMSServerConnections\n<\/li>\n<li>Verb-Noun\u00a0\u00a0\u00a0\u00a0(Practice I guess)\n<\/li>\n<\/ul>\n<p>It is a good start and may be something the community wants to create a community source project around at <a href=\"http:\/\/codeplex.com\/\">http:\/\/codeplex.com\/<\/a> . (hint hint hint).\n<\/p>\n<p>As I looked at the examples I saw a couple style things I would point out.  First one should be obvious to all PowerShell users: Get-Collections\/Get-ColllectionMembers.  What are the chances that this is going to collide with something else in the future?  Said another way, what are the chances that SMS is the only provider of &#8220;Collections&#8221;?  Clearly this and all the other commands should follow the example of Get-SMSServerConnections and put SMS in the noun name.\n<\/p>\n<p style=\"margin-left: 36pt\">I should point out a couple of things.\n<\/p>\n<ol style=\"margin-left: 54pt\">\n<li>As PowerShell, we&#8217;ll use the characters &#8220;PS&#8221; in front of our noun names.\n<\/li>\n<li>We will use generic noun names whenever we provide an extension point.  For example, in our V2 CTP, we have xxx-PSjobs.  If we turn this into an extensible framework for interacting with JOBs from a variety of sources, we&#8217;ll use the generic noun and rename these to xxx-JOBs.\n<\/li>\n<\/ol>\n<p>The one example that really caused me to write this post was:\n<\/p>\n<p><span style=\"font-family:Courier New;font-size:10pt\">Get-SMSServerConnection -server MYSMSSERVER | Get-Collections | where-object {$_.Name -eq &#8220;Windows Server 2003 Systems&#8221;} | Get-CollectionMembers | Disable-SoftwareDistribution\n<\/span><\/p>\n<p>\n\u00a0<\/p>\n<p>I&#8217;ve recently seen a number of cmdlets that do this pattern:\n<\/p>\n<p style=\"margin-left: 36pt\">Get-XXX | where {$_.Name \u2013match &#8220;xxx&#8221;\n<\/p>\n<p>I&#8217;d like to assert that selecting things by name (or ID) is a rockbed concept of GET and as such:\n<\/p>\n<ol style=\"margin-left: 54pt\">\n<li>Get Cmdlets should support \u2013NAME and\/or \u2013ID.\n<\/li>\n<li>This should be a positional parameter so that people don&#8217;t have to specify \u2013NAME.   e.g.:  Get-XXX   xxxxx\n<\/li>\n<li>Naming should support wildcards.  E.g.  Get-XXX   Win*systems\n<\/li>\n<\/ol>\n<p>I know that this will cause developers to spend more time on their Get Cmdlets but the improvement in User Experience will make this a very worthwhile investment.\n<\/p>\n<p>As a community of users \u2013 you should work with your vendors to stress these 2 points when you see their demos and try out their Betas.  At the end of the day, your wallet has much more power than my blog.  <span style=\"font-family:Wingdings\">J<\/span>\n\t<\/p>\n<p>Let me also declare that PowerShell is not without blame on either of this points.  Kenneth Hansen and I had dinner the other night and were bemoaning the fact that our Get-EventLog cmdlet did not support \u2013Index (which is the ID of a particular event message).  There are also a few examples where we should have used &#8220;PS&#8221; in our noun names and didn&#8217;t.  Apologizes for these shortcomings.\n<\/p>\n<p>Don  &#8211; thanks for this great article!  I think you might have started something.\n<\/p>\n<p>Jeffrey Snover [MSFT]<br \/>Windows Management Partner Architect<br \/>Visit the Windows PowerShell Team blog at:    <a href=\"http:\/\/blogs.msdn.com\/PowerShell\">http:\/\/blogs.msdn.com\/PowerShell<\/a><br \/>Visit the Windows PowerShell ScriptCenter at:  <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\">http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/a>\n\t<\/p>\n<p>\n\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just saw a cool article by Don Brown who has written a set of SMS Cmdlets for Windows PowerShell. These work with SMS 2003 and are well worth a look-see if you are an SMS customer. (Btw \u2013 I wrote Get-XXX to mean GET-(any nounname) but now that I look at it, it looks [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7031","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>I just saw a cool article by Don Brown who has written a set of SMS Cmdlets for Windows PowerShell. These work with SMS 2003 and are well worth a look-see if you are an SMS customer. (Btw \u2013 I wrote Get-XXX to mean GET-(any nounname) but now that I look at it, it looks [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/7031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=7031"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/7031\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=7031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=7031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=7031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}