It’s a Wonderful Shell—Chapter 4

Doctor Scripto

Summary: Microsoft PowerShell MVP and honorary Scripting Guy Sean Kearney continues with part 4 his five-part holiday series.

 Microsoft Scripting Guy, Ed Wilson, is here. Today we have part four of a five-part series of It’s a Wonderful Shell staring George Shelley. These are written by Windows PowerShell MVP Sean Kearney. For more information about the series, Sean’s biography, and a link to the series video teaser see the Scripting Guys Announce the Holiday Lineup blog post.

Image of George Shelley

It’s a Wonderful Shell—Chapter 4

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 …

… But mostly to amuse himself for a moment.

A quick tap on the shoulder brought him abruptly back to reality.

“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?”

George had to smile. Sam, good old Sam Coderight. Never COULD code worth a darn and always got the worst tasks.

“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?”

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’t get a break and was literally about to quit himself.

“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.”

Again, it seemed so obvious to George. All of this information was readily available in Windows via WMI. He remembered the look on Sam’s face when George ran a query again win32_computersystem in Windows PowerShell.

GET-WMIOBJECT win32_computersystem –computername CONTOSOWS1

Sam nearly fell over that day, blinking and stunned.

“Where did you get THAT from?” Staring at the output from the cmdlet.

Domain                                    : CONTOSO

Manufacturer                : FABRIKAM-PC                         

Model                          : 6000SUX

Name                          : CONTOSOWS1

TotalPhysicalMemory     : 2087518208

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.   

“Can you get me the number of physical CPUs as well?” His eyes lit up like a child staring at a very large and unprotected jar of cookies.

George remembered running the cmdlet through GET-MEMBER to show only the properties for Sam.

GET-WMIOBJECT win32_computersystem –computername CONTOSOWS1 | GET-MEMBER –Membertype Property *Processor*

With the resulting output …

   TypeName: System.Management.ManagementObject#root\cimv2\Win32_ComputerSystem

Name                                      MemberType     Definition

—-                                          ———-                        ———-

NumberOfLogicalProcessors      Property            uint32 NumberOfLogicalProcessors {get;set;}

NumberOfProcessors                Property            uint32 NumberOfProcessors {get;set;}

Sam nearly dropped his lucky Rubik’s cube on the floor when he saw what was available. “I can ask Windows? How do I ask it for the information?”

George showed his friend how to select the objects from the pipeline by using SELECT-OBJECT to show just the name of the computer, manufacturer, model, physical count of processors and total ram.

GET-WMIOBJECT win32_computersystem –computername CONTOSOWS1 | SELECT-OBJECT Name,Manufacturer,Model,NumberOfProcessors,TotalPhysicalMemory

How the little fellow danced about seeing the output.

Name                          : CONTOSOWS1

Manufacturer                : FABRIKAM-PC                         

Model                          : 6000SUX

NumberOfProcessors    : CONTOSOWS1

TotalPhysicalMemory     : 2087518208

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.

GET-WMIOBJECT win32_computersystem –computername CONTOSOWS1,CONTOSOFPS1,CONTOSOWS2 | SELECT-OBJECT Name,Manufacturer,Model,NumberOfProcessors,TotalPhysicalMemory | FORMAT-TABLE

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.

Name              Manufacturer     Model               NumberofProcessors      TotalPhysicalMemory

—-                  ————         —–                  ——————              ——————-

CONTOSOWS1 FABRIKAM-PC    6000SUX           1                                  2087518208

CONTOSOFPS   FABRIKAM-PC    MEGA310          32                                 8350072832

CONTOSOWS2 FABRIKAM-PC    6000SUX           2                                  521879552

 “Sam. We can just run pipe this output into a cmdlet called EXPORT-CSV to produce data that you can use Microsoft Excel to manipulate.”

GET-WMIOBJECT win32_computersystem –computername CONTOSOWS1,CONTOSOFPS1,CONTOSOWS2 | SELECT-OBJECT Name,Manufacturer,Model,NumberOfProcessors,TotalPhysicalMemory | EXPORT-CSV C:\Powershell\ComputerInventory.CSV

Clarence poked George gently to break him out of “lost in the memories” land. “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!”

“Because of that small effort in Windows PowerShell, Sam didn’t have to spend the weekend away and cancel a long-needed family vacation. You probably saved Sam’s marriage!” Clarence sat back triumphantly.

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.”

Realization began to touch our friend. Clarence was right.

Our good friend George Shelley was still saddened with his own problems, but brightened up by the differences he had made.

Suddenly Shiminy Cricket began to sing—only this time it didn’t seem so harsh. 

Thanks, Sean … Join us tomorrow as we have our exciting conclusion of It’s a Wonderful Shell.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy


Discussion is closed.

Feedback usabilla icon