Monthly Archive


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.

Leave a Reply