{"id":9431,"date":"2012-05-14T00:01:00","date_gmt":"2012-05-14T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2012\/05\/14\/discover-the-easy-way-to-begin-learning-windows-powershell\/"},"modified":"2012-05-14T00:01:00","modified_gmt":"2012-05-14T00:01:00","slug":"discover-the-easy-way-to-begin-learning-windows-powershell","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/discover-the-easy-way-to-begin-learning-windows-powershell\/","title":{"rendered":"Discover the Easy Way to Begin Learning Windows PowerShell"},"content":{"rendered":"<p><b>Summary<\/b>: Microsoft Scripting Guy, Ed Wilson, looks at Windows PowerShell naming conventions to simplify learning Windows PowerShell.<\/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;Hey, Scripting Guy! I have a feeling that I am quickly falling behind the Windows PowerShell wave. I am an Exchange Server admin where I work, and we are planning our deployment of Exchange Server&nbsp;2010. I was searching for information when I ran across some of your <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/tags\/windows+powershell\/microsoft+exchange+2010\/\" target=\"_blank\">blogs about using Windows PowerShell with Exchange Server 2010<\/a>. I quickly realized that I do not know very much about Windows PowerShell. Here is the problem, it seems like everyone else in the world knows way more about Windows PowerShell than I do. I know that when Windows Server &ldquo;8&rdquo; Beta ships, there will be even another version of Windows PowerShell. So should I wait until Windows Server &ldquo;8&rdquo; Beta and then learn the new Windows PowerShell, or should I begin learning the current version of Windows PowerShell?<\/p>\n<p>&mdash;GB<\/p>\n<p><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;Hello GB,<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. The other night, the Scripting Wife and I had dinner with Brian who is a member of the Charlotte Windows PowerShell User Group. In addition to answering lots of questions about Windows PowerShell and providing a decent amount of career guidance, the conversation also lingered for a while about tea. I thought about writing a blog called <i>The Fundamentals of Tea<\/i>&mdash;and I might do so on my personal blog. The problem is how does one describe the taste of Earl Gray tea to someone who has never tasted it before? Perhaps the best thing is to teach someone how to properly brew a nice cup of tea, and then allow them to taste some of my favorite teas. After all, there are literally hundreds of teas in the world, but they generally fall into just a few tea families. As you experience the flavors, you can find the types of tea that interest you.<\/p>\n<p>GB, the situation with learning Windows PowerShell is similar to learning about the world of tea. There are a few basic things you need to learn. A little grouping can be done to aid with the different types of Windows PowerShell cmdlets, and then from there, the process is one of exploring where your interests lie.<\/p>\n<h2>Windows PowerShell cmdlet naming helps you learn<\/h2>\n<p>One of the great things about Windows PowerShell is the verb-noun naming convention. In Windows PowerShell, the verbs indicate an action to perform, such as <b>Set<\/b> to make a change or <b>Get<\/b> to retrieve a value. The noun indicates the item with which to work such as a process or a service. By mastering the verb-noun naming convention, you can quickly hypothesize what a prospective command might be called. For example, if you need to obtain information about a process, and you know that Windows PowerShell uses the verb <b>Get<\/b> &nbsp;to retrieve information, you surmise that the command might very well be <b>Get-Process<\/b>. To obtain information about services you try <b>Get-Service<\/b>&hellip;and once again you are correct.<\/p>\n<p style=\"padding-left: 30px\"><b>Note&nbsp;&nbsp;&nbsp;<\/b>When &ldquo;guessing&rdquo; Windows PowerShell cmdlet names, always try the singular form first. Windows PowerShell prefers the singular form of nouns. It is not a design requirement, but it is a strong preference. Therefore, the cmdlets are named <b>Get-Service<\/b>, <b>Get-Process<\/b>, not <b>Get-Services<\/b> or <b>Get-Processes<\/b>.<\/p>\n<p>To see the list of approved verbs, use the <b>Get-Verb<\/b> cmdlet. This is shown here.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6735.hsg-5-14-12-01.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6735.hsg-5-14-12-01.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>There are nearly 100 approved verbs in Windows PowerShell&nbsp;2.0. This is shown in the command that follows where the <b>Measure-Object<\/b> cmdlet returns the count of verbs.<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; (get-verb | Measure-Object).count<\/p>\n<p style=\"padding-left: 30px\">96<\/p>\n<h2>Analyzing Windows PowerShell verb grouping<\/h2>\n<p>With nearly 100 verbs, you may be asking yourself, &ldquo;How does an array of 100 verbs assist in learning Windows PowerShell?&rdquo; You would be justified in asking that question. Nearly 100 different and unrelated items are really difficult to learn. However, the Windows PowerShell team grouped the verbs. For example, analyzing the common verbs reveals a pattern. The common verbs are listed here.<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; Get-Verb | where { $_.group -match &#8216;common&#8217;} | Format-Wide verb -AutoSize<\/p>\n<p style=\"padding-left: 30px\">Add&nbsp;&nbsp;&nbsp;&nbsp; Clear&nbsp; Close&nbsp; Copy&nbsp;&nbsp; Enter&nbsp; Exit&nbsp;&nbsp; Find&nbsp;&nbsp; Format Get&nbsp;&nbsp;&nbsp; Hide&nbsp;&nbsp; Join&nbsp;&nbsp; Lock<\/p>\n<p style=\"padding-left: 30px\">Move&nbsp;&nbsp;&nbsp; New&nbsp;&nbsp;&nbsp; Open&nbsp;&nbsp; Pop&nbsp;&nbsp;&nbsp; Push&nbsp;&nbsp; Redo&nbsp;&nbsp; Remove Rename Reset&nbsp; Search Select Set<\/p>\n<p style=\"padding-left: 30px\">Show&nbsp;&nbsp;&nbsp; Skip&nbsp;&nbsp; Split&nbsp; Step&nbsp;&nbsp; Switch Undo&nbsp;&nbsp; Unlock Watch<\/p>\n<p>The pattern for the verbs emerges when you analyze the verbs, for example: Add\/Remove, Enter\/Exit, Get\/Set, Select\/Skip, Lock\/Unlock, Push\/Pop, and so on. By learning the pattern to the common verbs, you quickly gain a handle on the Windows PowerShell naming convention.<\/p>\n<p>By using the Windows PowerShell verb grouping, you can determine where to focus your efforts. The following command lists the Windows PowerShell verb grouping.<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; Get-Verb | select group -Unique<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">Group<\/p>\n<p style=\"padding-left: 30px\">&#8212;&#8211;<\/p>\n<p style=\"padding-left: 30px\">Common<\/p>\n<p style=\"padding-left: 30px\">Data<\/p>\n<p style=\"padding-left: 30px\">Lifecycle<\/p>\n<p style=\"padding-left: 30px\">Diagnostic<\/p>\n<p style=\"padding-left: 30px\">Communications<\/p>\n<p style=\"padding-left: 30px\">Security<\/p>\n<p style=\"padding-left: 30px\">Other<\/p>\n<h2>Analyzing Windows PowerShell verb distribution<\/h2>\n<p>Another way to get a better handle on the Windows PowerShell cmdlets is to analyze the verb distribution. Although there are nearly 100 approved verbs (not to mention unapproved verbs that are used by rogue developers), only a fraction of them are utilized repeatedly, and some of them are not used at all in a standard Windows PowerShell installation. By using the <b>Group-Object<\/b> (<b>group<\/b> is an alias) and the <b>Sort-Object<\/b> cmdlets (<b>sort<\/b> is an alias), the distribution of the cmdlets quickly becomes evident. The following command shows the verb distribution.<\/p>\n<p style=\"padding-left: 30px\">Get-Command -CommandType cmdlet | group verb | sort count &ndash;Descending<\/p>\n<p>The command and the output associated with the command are shown in the image that follows.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3173.hsg-5-14-12-02.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3173.hsg-5-14-12-02.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>The preceding output makes it clear that most cmdlets only use a few of the verbs. In fact, most of the cmdlets use one of only 10 verbs. This is shown here.<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; Get-Command -CommandType cmdlet | group verb | sort count -Descending | selec<\/p>\n<p style=\"padding-left: 30px\">t -First 10<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">Count Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Group<\/p>\n<p style=\"padding-left: 30px\">&#8212;&#8211; &#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8211;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp; 46 Get&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {Get-Acl, Get-Alias, Get-AuthenticodeSignature, G&#8230;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp; 19 Set&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;{Set-Acl, Set-Alias, Set-AuthenticodeSignature, S&#8230;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp; 17 New&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {New-Alias, New-Event, New-EventLog, New-Item&#8230;}<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp; 14 Remove&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {Remove-Computer, Remove-Event, Remove-EventLog, &#8230;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; 8 Export&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {Export-Alias, Export-Clixml, Export-Console, Exp&#8230;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; 8 Write&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {Write-Debug, Write-Error, Write-EventLog, Write-&#8230;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; 7 Import&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {Import-Alias, Import-Clixml, Import-Counter, Imp&#8230;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; 7 Out&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {Out-Default, Out-File, Out-GridView, Out-Host&#8230;}<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; 6 Add&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {Add-Computer, Add-Content, Add-History, Add-Memb&#8230;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp; 6 Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {Start-Job, Start-Process, Start-Service, Start-S&#8230;<\/p>\n<p>In fact, of 236 cmdlets, 138 of the cmdlets use one of only 10 different verbs. This is shown here.<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; (Get-Command -CommandType cmdlet | measure).count<\/p>\n<p style=\"padding-left: 30px\">236<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; $count = 0 ; Get-Command -CommandType cmdlet | group verb | sort count -Descending |<\/p>\n<p style=\"padding-left: 30px\">select -First 10 | % {$count += $_.count ; $count}<\/p>\n<p style=\"padding-left: 30px\">46<\/p>\n<p style=\"padding-left: 30px\">65<\/p>\n<p style=\"padding-left: 30px\">82<\/p>\n<p style=\"padding-left: 30px\">96<\/p>\n<p style=\"padding-left: 30px\">104<\/p>\n<p style=\"padding-left: 30px\">112<\/p>\n<p style=\"padding-left: 30px\">119<\/p>\n<p style=\"padding-left: 30px\">126<\/p>\n<p style=\"padding-left: 30px\">132<\/p>\n<p style=\"padding-left: 30px\">138<\/p>\n<p>Therefore, GB, all you need to do is to master 10 verbs and you will have a good handle on more than half of the cmdlets that ship with Windows PowerShell&nbsp;2.0. Join me tomorrow when I will talk about more cool Windows PowerShell stuff.<\/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><b>Ed Wilson, Microsoft Scripting Guy<\/b>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, looks at Windows PowerShell naming conventions to simplify learning Windows PowerShell. &nbsp;Hey, Scripting Guy! I have a feeling that I am quickly falling behind the Windows PowerShell wave. I am an Exchange Server admin where I work, and we are planning our deployment of Exchange Server&nbsp;2010. I was searching [&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-9431","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, looks at Windows PowerShell naming conventions to simplify learning Windows PowerShell. &nbsp;Hey, Scripting Guy! I have a feeling that I am quickly falling behind the Windows PowerShell wave. I am an Exchange Server admin where I work, and we are planning our deployment of Exchange Server&nbsp;2010. I was searching [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/9431","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=9431"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/9431\/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=9431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=9431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=9431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}