PowerShell for Windows Admins

Dec 23 2013   5:55PM GMT

CDXML–NetworkAdapterConfiguration–Search on Index

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The Win32_NetworkAdapterConfiguration class has an Index and an InterfaceIndex property. Both are suitable search properties.

 

The take an unsigned integer as their value – leading to this addition to the CDXML file:

 

<Property PropertyName=”Index”>

<Type PSType = “System.UInt32″/>

<RegularQuery >

<CmdletParameterMetadata PSName=”Index” />

</RegularQuery>

</Property>

 

 

<Property PropertyName=”InterfaceIndex”>

<Type PSType = “System.UInt32″/>

<RegularQuery >

<CmdletParameterMetadata PSName=”InterfaceIndex” />

</RegularQuery>

</Property>

 

 

You can use the new parameters like this:

 

Get-NetworkAdapterConfiguration -Index 4

 

Get-NetworkAdapterConfiguration -InterfaceIndex 5

 

You should see by now how much easier it is working with cmdlets like this rather than having to remember the syntax for WQL filters and even the class names.

 

The full CDXML file looks 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_NetworkAdapterConfiguration’>

<Version>1.0</Version>

<DefaultNoun>NetworkAdapterConfiguration</DefaultNoun>

 

<InstanceCmdlets>

<GetCmdletParameters DefaultCmdletParameterSet=’DefaultSet’>

 

<QueryableProperties>

<Property PropertyName=”DHCPEnabled”>

<Type PSType = “System.Boolean”/>

<RegularQuery >

<CmdletParameterMetadata PSName=”DHCPEnabled” />

</RegularQuery>

</Property>

 

<Property PropertyName=”IPEnabled”>

<Type PSType = “System.Boolean”/>

<RegularQuery >

<CmdletParameterMetadata PSName=”IPEnabled” />

</RegularQuery>

</Property>

 

<Property PropertyName=”Index”>

<Type PSType = “System.UInt32″/>

<RegularQuery >

<CmdletParameterMetadata PSName=”Index” />

</RegularQuery>

</Property>

 

<Property PropertyName=”InterfaceIndex”>

<Type PSType = “System.UInt32″/>

<RegularQuery >

<CmdletParameterMetadata PSName=”InterfaceIndex” />

</RegularQuery>

</Property>

 

</QueryableProperties>

 

</GetCmdletParameters>

</InstanceCmdlets>

</Class>

</PowerShellMetadata>

 

The module manifest file hasn’t needed to be changed to add this additional functionality. One of the great things about CDXML is that once you have the basic cmdlet working it is so easy to add extra parameters.

 

The next step is to use some of the methods on the class

 

 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: