{"id":7951,"date":"2015-02-09T00:01:00","date_gmt":"2015-02-09T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2015\/02\/09\/dont-learn-powershell-use-powershell\/"},"modified":"2019-02-18T10:30:42","modified_gmt":"2019-02-18T17:30:42","slug":"dont-learn-powershell-use-powershell","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/dont-learn-powershell-use-powershell\/","title":{"rendered":"Don&#8217;t Learn PowerShell, Use PowerShell"},"content":{"rendered":"<p><b style=\"font-size:12px\">Summary<\/b><span style=\"font-size:12px\">: Microsoft Scripting Guy, Ed Wilson, talks about getting started with Windows PowerShell.<\/span><\/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 get it. I need to learn Windows PowerShell&mdash;I see it mentioned everywhere. The problem is that I don&rsquo;t have five years to learn the stuff. And besides that, by the time that five years has passed, you guys will probably come out with at least two new versions of Windows PowerShell. So if I spend five years trying to learn Windows PowerShell&nbsp;4.0, by the time I am done learning it, I will still be three or four versions behind. I feel like I can never catch up&mdash;like a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Hamster_wheel\" target=\"_blank\">hamster running around on a wheel<\/a>. I never seem to make any progress. What can I do?<\/p>\n<p>&mdash;GM<\/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 GM,<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. I just got back from the gym. Luckily, the gym I go to is open 24 hours a day, so I can get up early and get back to still start my day. I kind of know what you are talking about. I did three miles on the treadmill this morning&mdash;and in the end, I never really moved an inch of distance.<\/p>\n<p>GM, I can see what you are talking about, but you are basing your argument on a false argument. You do not need to learn everything there is about Windows PowerShell to use it. In fact, the vast majority of IT pros never write a single Windows PowerShell script. The difference between Windows PowerShell and VBScript (or some other scripting language) is that Windows PowerShell is not only a scripting language. In fact, it is possible to use Windows PowerShell without learning Windows PowerShell at all. This is because Windows PowerShell is an interactive environment in addition to a scripting language. Your problem has given me a good reason to introduce Don&#039;t Learn PowerShell Week.<\/p>\n<h2>Windows PowerShell ISE: Not only for scripts<\/h2>\n<p>The Windows PowerShell ISE is not only for writing scripts. In fact, I use it nearly all the time. The reason is that it is a great interactive console, and if I have more than a single command I want to type, I can move to the script pane, type my commands, and then run them. I do not have to write a script. The Windows PowerShell ISE is shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-01.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-01.png\" alt=\"Image of Windows PowerShell ISE\" title=\"Image of Windows PowerShell ISE\" \/><\/a><\/p>\n<p>The upper white box is the script pane. The bottom blue box is the interactive Windows PowerShell console. It is also where the output from the script pane appears. The right pane is the <b>Command Add-on<\/b>. By default, when the Windows PowerShell ISE first launches, the <b>Command Add-on<\/b> appears. If I close it by clicking the &ldquo;X&rdquo; in the upper-right corner of the <b>Command Add-on<\/b> or by clearing the <b>Show Command Add-on<\/b> menu item (as shown in the following image), the next time I launch the Windows PowerShell ISE, the <b>Command Add-on<\/b> does not open. If I later decide that I want the <b>Command Add-on<\/b>, I select <b>Show Command Add-on<\/b> in the <b>View<\/b> menu.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-02.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-02.png\" alt=\"Image of menu\" title=\"Image of menu\" \/><\/a><\/p>\n<h3>What good is the Command Add-on anyway?<\/h3>\n<p>The <b>Command Add-on<\/b> is a great tool because it permits me to build commands on the fly. It also permits me to find Windows PowerShell cmdlets without knowing anything about the cmdlet name or about Windows PowerShell verbs or nouns. For more experienced Windows PowerShell users, it is a great tool to use when demonstrating to beginners how Windows PowerShell works.<\/p>\n<h3>First find the command<\/h3>\n<p>Obviously, the first thing to do is find the appropriate Windows PowerShell command. Windows PowerShell commands are often cmdlets&mdash;as in a little command. Notice that by default, the <b>Modules<\/b><i> <\/i>text box is set to <b>All<\/b><i>. <\/i>If I know what module contains the command I want to use, I can select that module from the drop-down list. But when starting out, I would not even know what a module is, and I would definitely not know which module might contain the command I am interested in using. So I leave <b>Modules<\/b><i> <\/i>set to <b>All<\/b><i>, <\/i>and I begin typing in the <b>Name<\/b><i> <\/i>text box. As I type, the cmdlets filter out until I am left with only a few cmdlets, as shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-03.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-03.png\" alt=\"Image of Windows PowerShell ISE\" title=\"Image of Windows PowerShell ISE\" \/><\/a><\/p>\n<p>I look at the commands, and I see that some of them contain the word <b>VMProcessor<\/b>. I might guess that it has something to do with a virtual machine (because of the letters VM). Other commands, such as <b>Debug-Process<\/b>, <b>Start-Process<\/b>, and <b>Stop-Process<\/b> appear to be self-explanatory: <b>Debug-Process<\/b> probably has something to do with debugging a process, and <b>Start-Process<\/b> and <b>Stop-Process<\/b> probably permit me to start or stop a process.<\/p>\n<p>One of the nice things about Windows PowerShell is most of the cmdlet names tend to make sense. (This is unlike the old-fashioned type of command names, such as <b>SC<\/b>, which seem to have very little relationship to anything.)<\/p>\n<p>If I select the <b>Get-Process<\/b> cmdlet from the filtered <b>Command<\/b> window, the bottom pane immediately changes to display the parameters for <b>Get-Process<\/b>. This is shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-04.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-04.png\" alt=\"Image of Windows PowerShell ISE\" title=\"Image of Windows PowerShell ISE\" \/><\/a><\/p>\n<p>Each parameter set (ways of using the cmdlet) appears on a different tab. The default is <b>Name<\/b><i>, <\/i>and it appears as the one that is automatically selected. I can add the target <b>ComputerName<\/b>. I can also choose to display file versioning or module information by selecting the <b>FileVersionInfo<\/b> or <b>Module<\/b> options. In addition, I can limit the information that is returned to a specific process by entering the process name in the <b>Name<\/b><i> <\/i>text box.<\/p>\n<p>When I have completed my selections, I have three choices. I can run the command immediately and display the output from the command by pressing the <b>Run<\/b> button. This is shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-05.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-05.png\" alt=\"Image of Windows PowerShell ISE\" title=\"Image of Windows PowerShell ISE\" \/><\/a><\/p>\n<p>Alternatively, if I press the <b>Insert<\/b> button, the command appears in the interactive Windows PowerShell command window, but it does not execute. This permits me to make changes to the command, or to add additional commands to the command line prior to running the command.<\/p>\n<p>In the following image, I have cleared the output from the previous command by pressing the <b>Window wiper, squeegee<\/b>, which is located on the <b>Add-ons<\/b> menu. Notice that the <b>Get-Process<\/b> command appears on the first line in the Windows PowerShell console, but it has not yet run.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-06.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-06.png\" alt=\"Image of Windows PowerShell ISE\" title=\"Image of Windows PowerShell ISE\" \/><\/a><\/p>\n<p>If I want the command in the script pane, I need to click the <b>Copy<\/b> button to place the command on the clipboard. I then paste it into the script pane at the appropriate location. This is shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-07.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-2-9-15-07.png\" alt=\"Image of Windows PowerShell ISE\" title=\"Image of Windows PowerShell ISE\" \/><\/a><\/p>\n<p>So, by using the Windows PowerShell <b>Command Add-on<\/b> pane, I can easily find, create, and execute Windows PowerShell commands on the fly without having an in-depth knowledge of Windows PowerShell.<\/p>\n<p>GM, that is all there is to using the <b>Show-Command<\/b> command. Don&rsquo;t Learn PowerShell Week will continue tomorrow when I will talk about more cool 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><span style=\"font-size:12px\">&nbsp;<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about getting started with Windows PowerShell. &nbsp;Hey, Scripting Guy! I get it. I need to learn Windows PowerShell&mdash;I see it mentioned everywhere. The problem is that I don&rsquo;t have five years to learn the stuff. And besides that, by the time that five years has passed, you guys [&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,45],"class_list":["post-7951","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-getting-started","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about getting started with Windows PowerShell. &nbsp;Hey, Scripting Guy! I get it. I need to learn Windows PowerShell&mdash;I see it mentioned everywhere. The problem is that I don&rsquo;t have five years to learn the stuff. And besides that, by the time that five years has passed, you guys [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/7951","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=7951"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/7951\/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=7951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=7951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=7951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}