PowerShell for Windows Admins

Dec 2 2013   12:01PM GMT

CDXML: Add a cmdlet for computer system

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

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=”http://schemas.microsoft.com/cmdlets-over-objects/2009/11″>

<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 : Manticore.org

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.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: