CDXML: Add a cmdlet for computer system

Continuing the creation of a Hardware investigation module – its a simple matter to add a cmdlet to retrieve the computer system data ie Win32_ComputerSystem

First create a CDXML file like this:

<?xml version=”1.0″ encoding=”utf-8″?>
<PowerShellMetadata xmlns=”″>
  <Class ClassName=”ROOT\cimv2\Win32_ComputerSystem”>

      <GetCmdletParameters DefaultCmdletParameterSet=”DefaultSet”>


The only difference from the Win32_BIOS.cdxml is the WMI class and the default noun

Save in your Hardware module folder as Win32_ComputerSystem.cdxml

Modify the hardware.psd1 file in two places –

NestedModules = @(‘Win32_BIOS.cdxml’,
                  ‘Win32_ComputerSystem.cdxml’ )



FunctionsToExport = @(‘Get-Bios’,

Save the hardware.psd1 file.

Now when you open up PowerShell

£> Get-Command -Module Hardware

CommandType     Name                  ModuleName
———–     —-                  ———-
Function        Get-Bios              Hardware
Function        Get-ComputerSystem    Hardware


£> Get-ComputerSystem | Format-List

Domain              :
Manufacturer        : Microsoft Corporation
Model               : Virtual Machine
Name                : WIN81
PrimaryOwnerName    : Richard
TotalPhysicalMemory : 1857605632

Note default display is a table.

For now we’ll keep adding investigative cmdlets to our module – though there are some methods on Win32_ComputerSystem we’ll be adding to our module later.

This entry was posted in CDXML, CIM, PowerShell and WMI, PowerShell V3, PowerShell v4. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s