{"id":4431,"date":"2012-12-24T00:01:00","date_gmt":"2012-12-24T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2012\/12\/24\/its-a-wonderful-shellchapter-4\/"},"modified":"2012-12-24T00:01:00","modified_gmt":"2012-12-24T00:01:00","slug":"its-a-wonderful-shellchapter-4","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/its-a-wonderful-shellchapter-4\/","title":{"rendered":"It&#8217;s a Wonderful Shell&#8212;Chapter 4"},"content":{"rendered":"<p><strong>Summary:<\/strong> Microsoft PowerShell MVP and honorary Scripting Guy Sean Kearney continues with part 4 his five-part holiday series.<\/p>\n<p>&nbsp;Microsoft Scripting Guy, Ed Wilson, is here. Today we have part four of a five-part series of <em>It&rsquo;s a Wonderful Shell <\/em>staring George Shelley. These are written by Windows PowerShell MVP Sean Kearney. For more information about the series, Sean&rsquo;s biography, and a link to the series video teaser see the <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2012\/12\/20\/scripting-guys-announce-the-holiday-lineup.aspx\" target=\"_blank\">Scripting Guys Announce the Holiday Lineup<\/a> blog post.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0552.Scripting-Guy_Holiday.png\"><img decoding=\"async\" title=\"Image of George Shelley\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0552.Scripting-Guy_Holiday.png\" alt=\"Image of George Shelley\" \/><\/a><\/p>\n<h1 style=\"padding-left: 30px\">It&rsquo;s a Wonderful Shell&mdash;Chapter 4<\/h2>\n<p style=\"padding-left: 30px\">George stared into the ceiling and began to count stucco holes, partly to meditate on what Clarence brought forth to light in his positive contributions with Windows PowerShell &hellip;<\/p>\n<p style=\"padding-left: 30px\">&hellip; But mostly to amuse himself for a moment.<\/p>\n<p style=\"padding-left: 30px\">A quick tap on the shoulder brought him abruptly back to reality.<\/p>\n<p style=\"padding-left: 30px\">&ldquo;George. You seem to forget that those things you do in Windows PowerShell daily contribute to a much larger picture. Now, of course you remember your co-worker Sam?&rdquo;<\/p>\n<p style=\"padding-left: 30px\">George had to smile. Sam, good old Sam Coderight. Never COULD code worth a darn and always got the worst tasks.<\/p>\n<p style=\"padding-left: 30px\">&ldquo;I seem to remember quite vividly for weeks Sam trying to physically inventory all of the computers and monitors in the office. He had to get an accurate inventory of each machine including the model of the monitor and computer. Do you remember how frustrated HE was?&rdquo;<\/p>\n<p style=\"padding-left: 30px\">It was true. Sam had been tasked to examine over 200 systems and yield an accurate inventory. He was manually running tools, checking monitors, and writing down models. The poor guy couldn&rsquo;t get a break and was literally about to quit himself.<\/p>\n<p style=\"padding-left: 30px\">&ldquo;Now he WAS about to quit when a certain IT pro named George Shelley sat down with him and helped him out with Windows PowerShell.&rdquo;<\/p>\n<p style=\"padding-left: 30px\">Again, it seemed so obvious to George. All of this information was readily available in Windows via WMI. He remembered the look on Sam&rsquo;s face when George ran a query again win32_computersystem in Windows PowerShell.<\/p>\n<p style=\"padding-left: 60px\">GET-WMIOBJECT win32_computersystem &ndash;computername CONTOSOWS1<\/p>\n<p style=\"padding-left: 30px\">Sam nearly fell over that day, blinking and stunned.<\/p>\n<p style=\"padding-left: 30px\">&ldquo;Where did you get THAT from?&rdquo; Staring at the output from the cmdlet.<\/p>\n<p style=\"padding-left: 60px\">Domain&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : CONTOSO<\/p>\n<p style=\"padding-left: 60px\">Manufacturer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : FABRIKAM-PC&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"padding-left: 60px\">Model&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 6000SUX<\/p>\n<p style=\"padding-left: 60px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : CONTOSOWS1<\/p>\n<p style=\"padding-left: 60px\">TotalPhysicalMemory&nbsp;&nbsp;&nbsp;&nbsp; : 2087518208<\/p>\n<p style=\"padding-left: 30px\">Sam had a particularly difficult time since he recently lost the file that contained all of the memory configurations and had to restart most of his task.&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"padding-left: 30px\">&ldquo;Can you get me the number of physical CPUs as well?&rdquo; His eyes lit up like a child staring at a very large and unprotected jar of cookies.<\/p>\n<p style=\"padding-left: 30px\">George remembered running the cmdlet through <strong>GET-MEMBER<\/strong> to show only the properties for Sam.<\/p>\n<p style=\"padding-left: 60px\">GET-WMIOBJECT win32_computersystem &ndash;computername CONTOSOWS1 | GET-MEMBER &ndash;Membertype Property *Processor*<\/p>\n<p style=\"padding-left: 30px\">With the resulting output &hellip;<\/p>\n<p style=\"padding-left: 60px\">&nbsp;&nbsp; TypeName: System.Management.ManagementObject#root\\cimv2\\Win32_ComputerSystem<\/p>\n<p style=\"padding-left: 60px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemberType&nbsp;&nbsp;&nbsp;&nbsp; Definition<\/p>\n<p style=\"padding-left: 60px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;-<\/p>\n<p style=\"padding-left: 60px\">NumberOfLogicalProcessors &nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint32 NumberOfLogicalProcessors {get;set;}<\/p>\n<p style=\"padding-left: 60px\">NumberOfProcessors&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint32 NumberOfProcessors {get;set;}<\/p>\n<p style=\"padding-left: 30px\">Sam nearly dropped his lucky Rubik&rsquo;s cube on the floor when he saw what was available. &ldquo;I can ask Windows? How do I ask it for the information?&rdquo;<\/p>\n<p style=\"padding-left: 30px\">George showed his friend how to select the objects from the pipeline by using <strong>SELECT-OBJECT<\/strong> to show just the name of the computer, manufacturer, model, physical count of processors and total ram.<\/p>\n<p style=\"padding-left: 60px\">GET-WMIOBJECT win32_computersystem &ndash;computername CONTOSOWS1 | SELECT-OBJECT Name,Manufacturer,Model,NumberOfProcessors,TotalPhysicalMemory<\/p>\n<p style=\"padding-left: 30px\">How the little fellow danced about seeing the output.<\/p>\n<p style=\"padding-left: 60px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : CONTOSOWS1<\/p>\n<p style=\"padding-left: 60px\">Manufacturer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : FABRIKAM-PC&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"padding-left: 60px\">Model&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 6000SUX<\/p>\n<p style=\"padding-left: 60px\">NumberOfProcessors&nbsp;&nbsp;&nbsp; : CONTOSOWS1<\/p>\n<p style=\"padding-left: 60px\">TotalPhysicalMemory&nbsp;&nbsp;&nbsp;&nbsp; : 2087518208<\/p>\n<p style=\"padding-left: 30px\">He remembered how brightly Sam lit up when George showed him how he could ask for the same information from a list of computers and display the output as a table.<\/p>\n<p style=\"padding-left: 60px\">GET-WMIOBJECT win32_computersystem &ndash;computername CONTOSOWS1,CONTOSOFPS1,CONTOSOWS2 | SELECT-OBJECT Name,Manufacturer,Model,NumberOfProcessors,TotalPhysicalMemory | FORMAT-TABLE<\/p>\n<p style=\"padding-left: 30px\">George had almost choked on his coffee when SAM had tried to use Copy\/Paste to get the information on the screen he saw below.<\/p>\n<p style=\"padding-left: 60px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Manufacturer&nbsp;&nbsp;&nbsp;&nbsp; Model&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NumberofProcessors&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TotalPhysicalMemory<\/p>\n<p style=\"padding-left: 60px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8211;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&nbsp;&nbsp;&n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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 521879552<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&ldquo;Sam. We can just run pipe this output into a cmdlet called <strong>EXPORT-CSV<\/strong> to produce data that you can use Microsoft Excel to manipulate.&rdquo;<\/p>\n<p style=\"padding-left: 60px\">GET-WMIOBJECT win32_computersystem &ndash;computername CONTOSOWS1,CONTOSOFPS1,CONTOSOWS2 | SELECT-OBJECT Name,Manufacturer,Model,NumberOfProcessors,TotalPhysicalMemory | EXPORT-CSV C:\\Powershell\\ComputerInventory.CSV<\/p>\n<p style=\"padding-left: 30px\">Clarence poked George gently to break him out of &ldquo;lost in the memories&rdquo; land. &ldquo;Do you remember how HAPPY Sam was that day? Because of you, he was able to complete his work on time AND without having to spend the weekend at work!&rdquo;<\/p>\n<p style=\"padding-left: 30px\">&ldquo;Because of that small effort in Windows PowerShell, Sam didn&rsquo;t have to spend the weekend away and cancel a long-needed family vacation. You probably saved Sam&rsquo;s marriage!&rdquo; Clarence sat back triumphantly.<\/p>\n<p style=\"padding-left: 30px\">George never thought about things in that aspect. It took so little on his part to make a difference. He never considered how much others not only appreciated his effort but how much of a difference it made.&rdquo;<\/p>\n<p style=\"padding-left: 30px\">Realization began to touch our friend. Clarence was right.<\/p>\n<p style=\"padding-left: 30px\">Our good friend George Shelley was still saddened with his own problems, but brightened up by the differences he had made.<\/p>\n<p style=\"padding-left: 30px\">Suddenly Shiminy Cricket began to sing&mdash;only this time it didn&rsquo;t seem so harsh.&nbsp;<\/p>\n<p>Thanks, Sean &hellip; Join us tomorrow as we have our exciting conclusion of <em>It&rsquo;s a Wonderful Shell<\/em>.<\/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><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft PowerShell MVP and honorary Scripting Guy Sean Kearney continues with part 4 his five-part holiday series. &nbsp;Microsoft Scripting Guy, Ed Wilson, is here. Today we have part four of a five-part series of It&rsquo;s a Wonderful Shell staring George Shelley. These are written by Windows PowerShell MVP Sean Kearney. For more information about [&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":[56,392,3,154,61,45],"class_list":["post-4431","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-guest-blogger","tag-holiday-2013","tag-scripting-guy","tag-sean-kearney","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft PowerShell MVP and honorary Scripting Guy Sean Kearney continues with part 4 his five-part holiday series. &nbsp;Microsoft Scripting Guy, Ed Wilson, is here. Today we have part four of a five-part series of It&rsquo;s a Wonderful Shell staring George Shelley. These are written by Windows PowerShell MVP Sean Kearney. For more information about [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4431","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=4431"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4431\/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=4431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=4431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=4431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}