{"id":4901,"date":"2009-01-02T16:35:02","date_gmt":"2009-01-02T16:35:02","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2009\/01\/02\/get-verb\/"},"modified":"2019-02-18T13:12:59","modified_gmt":"2019-02-18T20:12:59","slug":"get-verb","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/get-verb\/","title":{"rendered":"Get-Verb"},"content":{"rendered":"<p>    .cmdletname { font-size:large }\n    .cmdletsynopsis { font-size:medium }\n    .cmdletdescription { font-size:medium }\n    .cmdletparameters { font-size:medium }\n    th {\n        font-size: medium;\n        font-style: italic\n    }\n    table {\n        border: 1\n    }  <\/p>\n<p class=\"PostHeader\">When I write a PowerShell function, I try to ensure that it follows the PowerShell standard verbs. These verbs actually exist as static properties in a few different types in PowerShell, so I thought I&#8217;d make a quick advanced function so I can get all of the Verbs. Check it out:<\/p>\n<p class=\"CmdletName\">Get-Verb<\/p>\n<p>  <\/p>\n<p class=\"CmdletSynopsis\"><b>Synopsis:<\/b>    <\/p>\n<blockquote><p>Gets the standard PowerShell verbs <\/p><\/blockquote>\n<p>  <\/p>\n<p class=\"CmdletSyntax\"><b>Syntax:<\/b>    <\/p>\n<blockquote><p>Get-Verb [[-verb] [&lt;String[]&gt;]] [-Verbose] [-Debug] [-ErrorAction [&lt;ActionPreference&gt;]] [-WarningAction [&lt;ActionPreference&gt;]] [-ErrorVariable [&lt;String&gt;]] [-WarningVariable [&lt;String&gt;]] [-OutVariable [&lt;String&gt;]] [-OutBuffer [&lt;Int32&gt;]] [&lt;CommonParameters&gt;] <\/p><\/blockquote>\n<p>  <\/p>\n<p class=\"CmdletDescription\"><b>Detailed Description:<\/b>    <\/p>\n<blockquote><p>Uses reflection to get the standard PowerShell verbs and return them as a property bag <\/p><\/blockquote>\n<p>  <\/p>\n<p class=\"Examples\">Examples: <\/p>\n<blockquote>\n<pre class=\"CmdletExample\">    -------------------------- EXAMPLE 1 --------------------------\n# Gets all verbs\nGet-Verb\n    <\/pre>\n<\/blockquote>\n<blockquote>\n<pre class=\"CmdletExample\">    -------------------------- EXAMPLE 2 --------------------------\n# Gets a random verb and searches for commands with that verb\nGet-Verb | Get-Random | Get-Command\n    <\/pre>\n<\/blockquote>\n<blockquote>\n<pre class=\"CmdletExample\">    -------------------------- EXAMPLE 3 --------------------------\nGet-Verb &quot;S*&quot;\n    <\/pre>\n<\/blockquote>\n<p><\/p>\n<p class=\"CmdletParameters\">Command Parameters: <\/p>\n<blockquote>\n<table>\n<colgroup>\n<col \/>\n<col \/><\/colgroup>\n<tbody>\n<tr>\n<th>Name<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>verb<\/td>\n<td>The verb names to filter on (optional)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/blockquote>\n<p><\/p>\n<p>Here&#8217;s Get-Verb: <i><\/i><\/p>\n<blockquote>\n<pre class=\"CmdletDefinition\">function Get-Verb {\n    &lt;#\n    .Synopsis\n        Gets the standard PowerShell verbs\n    .Description\n        Uses reflection to get the standard PowerShell verbs and return them as a property bag\n    .Parameter verb\n        The verb names to filter on (optional)\n    .Example\n        # Gets all verbs\n        Get-Verb\n    .Example\n        # Gets a random verb and searches for commands with that verb\n        Get-Verb | Get-Random | Get-Command\n    .Example\n        Get-Verb &quot;S*&quot;\n    #&gt;\n    param(\n        [Parameter(ValueFromPipeline=$true,Position=0)]\n        [string[]]\n        $verb = &quot;*&quot;\n    )\nbegin {\n        $allVerbs = [PSObject].Assembly.GetTypes() |\n            Where-Object {$_.Name -like &quot;*Verbs*&quot;} |\n            Get-Member -type Property -static |\n            Select-Object @{\n                Name='Verb'\n                Expression = {$_.Name}\n            }, @{\n                Name='Group'\n                Expression = {\n                    $str = &quot;$($_.TypeName)&quot;\n                    $str.Substring($str.LastIndexOf(&quot;Verbs&quot;) + 5)\n                }\n            }, @{\n                Name='Type'\n                Expression = { $_.TypeName -as [Type] }\n            }\n}\nprocess {\n        foreach ($v in $verb) {\n            $allVerbs | Where-Object { $_.Verb -like $v }\n        }\n}\n}\n    <\/pre>\n<\/blockquote>\n<\/p>\n<p class=\"Postfooter\">Hope This Helps,<\/p>\n<p class=\"Postfooter\">James Brundage [MSFT]<\/p>\n<p style=\"font-size: xx-small\">Automatically generated with <a href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/tags\/Write-CommandBlogPost\/default.aspx\">Write-CommandBlogPost<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>.cmdletname { font-size:large } .cmdletsynopsis { font-size:medium } .cmdletdescription { font-size:medium } .cmdletparameters { font-size:medium } th { font-size: medium; font-style: italic } table { border: 1 } When I write a PowerShell function, I try to ensure that it follows the PowerShell standard verbs. These verbs actually exist as static properties in a few [&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":[97,182],"class_list":["post-4901","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-advanced-functions","tag-get-verb"],"acf":[],"blog_post_summary":"<p>.cmdletname { font-size:large } .cmdletsynopsis { font-size:medium } .cmdletdescription { font-size:medium } .cmdletparameters { font-size:medium } th { font-size: medium; font-style: italic } table { border: 1 } When I write a PowerShell function, I try to ensure that it follows the PowerShell standard verbs. These verbs actually exist as static properties in a few [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/4901","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=4901"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/4901\/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=4901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=4901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=4901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}