{"id":3021,"date":"2013-08-17T00:01:00","date_gmt":"2013-08-17T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/08\/17\/weekend-scripter-understanding-powershell-in-windows-7\/"},"modified":"2013-08-17T00:01:00","modified_gmt":"2013-08-17T00:01:00","slug":"weekend-scripter-understanding-powershell-in-windows-7","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/weekend-scripter-understanding-powershell-in-windows-7\/","title":{"rendered":"Weekend Scripter: Understanding PowerShell in Windows 7"},"content":{"rendered":"<p><strong>Summary<\/strong>: Microsoft Scripting Guy, Ed Wilson, talks about understanding Windows PowerShell in Windows 7.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. This morning I am sipping a cup of English Breakfast tea, with <a href=\"http:\/\/en.wikipedia.org\/wiki\/Wolfberry\" target=\"_blank\">goji berries<\/a>, lemon grass, and cinnamon. The taste is quite nice, and because the goji berries are sweet, I do not need to add any sugar or honey to my tea. Goji berries are not indigenous to Charlotte, North Carolina, so I use dried berries that I order with my other herbs and spices. Along with my tea, I am eating some homemade scones that the Scripting Wife made with the goji berries. They are rather lovely.<\/p>\n<p>One of the more common questions I get about Windows PowerShell&nbsp;3.0 runs something like this,&ldquo;I have Windows PowerShell&nbsp;3.0, but I do not see the <strong>Get-Disk<\/strong> cmdlet.&rdquo; (Or words to that effect.) Part of the confusion stems from confusing Windows PowerShell&nbsp;3.0 with the operating system.<\/p>\n<p style=\"padding-left: 30px\"><strong>Note<\/strong> &nbsp;&nbsp;For information about installation, refer to <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/06\/02\/weekend-scripter-install-powershell-3-0-on-windows-7.aspx\" target=\"_blank\">Install PowerShell 3.0 on Windows 7<\/a>.<\/p>\n<p>For example, in Windows 7, when I install Windows PowerShell&nbsp;3.0, I have access to 355 cmdlets and functions. To find this information, I first imported all of the modules, and then I used the <strong>Get-Command<\/strong> cmdlet to retrieve all functions and cmdlets. This is shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3704.HSG-8-17-13-01.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3704.HSG-8-17-13-01.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>In Windows 8, I do not need to install Windows PowerShell&nbsp;3.0 because it is part of the operating system. When I import all of the modules and count the number of cmdlets and functions in Windows&nbsp;8, I come up with 988. The output is shown in the following image.<\/p>\n<p style=\"padding-left: 30px\"><strong>Note<\/strong> &nbsp;Interestingly enough, the output from <strong>$PSVersionTable<\/strong> is a little different in Windows&nbsp;7 and Windows&nbsp;8.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6758.HSG-8-17-13-02.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6758.HSG-8-17-13-02.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<h2>Look at the modules<\/h2>\n<p>So, where does the difference between Windows PowerShell&nbsp;3.0 in Windows 7 and In Windows&nbsp;8 come from? Well, it comes from the modules. In Windows&nbsp;8, many of the teams at Microsoft created modules to permit remote management of aspects of their configuration. In many cases, this took the form of wrapping various WMI classes that have been part of the operating system for a long time. Therefore, just because I am working in Windows&nbsp;7, it does not mean that I am unable to use Windows PowerShell to manage it&mdash;but it will be a bit more difficult.<\/p>\n<p>So what are the modules that are available in Windows&nbsp;7 after I install Windows PowerShell&nbsp;3.0? They are listed here:<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; Get-Module -list | select name<\/p>\n<p style=\"padding-left: 30px\">Name<\/p>\n<p style=\"padding-left: 30px\">&#8212;-<\/p>\n<p style=\"padding-left: 30px\">AppLocker<\/p>\n<p style=\"padding-left: 30px\">BitsTransfer<\/p>\n<p style=\"padding-left: 30px\">CimCmdlets<\/p>\n<p style=\"padding-left: 30px\">ISE<\/p>\n<p style=\"padding-left: 30px\">Microsoft.PowerShell.Diagnostics<\/p>\n<p style=\"padding-left: 30px\">Microsoft.PowerShell.Host<\/p>\n<p style=\"padding-left: 30px\">Microsoft.PowerShell.Management<\/p>\n<p style=\"padding-left: 30px\">Microsoft.PowerShell.Security<\/p>\n<p style=\"padding-left: 30px\">Microsoft.PowerShell.Utility<\/p>\n<p style=\"padding-left: 30px\">Microsoft.WSMan.Management<\/p>\n<p style=\"padding-left: 30px\">PSDiagnostics<\/p>\n<p style=\"padding-left: 30px\">PSScheduledJob<\/p>\n<p style=\"padding-left: 30px\">PSWorkflow<\/p>\n<p style=\"padding-left: 30px\">PSWorkflowUtility<\/p>\n<p style=\"padding-left: 30px\">TroubleshootingPack<\/p>\n<p>To get an idea of the number of cmdlets in each module, I decide to create a custom property in the <strong>Select-Object<\/strong> cmdlet. Here is the command that I created (this is a single-line command that I broke into multiple lines for easier reading):<\/p>\n<p style=\"padding-left: 30px\">Get-Module -list | select name,<\/p>\n<p style=\"padding-left: 30px\">@{L=&#8217;commands&#8217;;E={(Get-command -commandtype Function, Cmdlet -module $_.name).count}} |<\/p>\n<p style=\"padding-left: 30px\">sort commands -Descending| ft &ndash;auto<\/p>\n<p>The command and its associated output are shown in the following image:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8054.HSG-8-17-13-03.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8054.HSG-8-17-13-03.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>By examining the modules and the cmdlets, I can see where the Windows PowerShell&nbsp;3.0 cmdlets and functions reside, and determine from whence they actually come.<\/p>\n<p>Join me tomorrow when I will examine Windows PowerShell&nbsp;3.0 in Windows&nbsp;8.<\/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><strong>Ed Wilson, Microsoft Scripting Guy<\/strong>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about understanding Windows PowerShell in Windows 7. Microsoft Scripting Guy, Ed Wilson, is here. This morning I am sipping a cup of English Breakfast tea, with goji berries, lemon grass, and cinnamon. The taste is quite nice, and because the goji berries are sweet, I do not need [&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,61,45],"class_list":["post-3021","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-getting-started","tag-scripting-guy","tag-scripting-techniques","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about understanding Windows PowerShell in Windows 7. Microsoft Scripting Guy, Ed Wilson, is here. This morning I am sipping a cup of English Breakfast tea, with goji berries, lemon grass, and cinnamon. The taste is quite nice, and because the goji berries are sweet, I do not need [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/3021","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=3021"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/3021\/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=3021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=3021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=3021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}