CDXML–NetworkAdapterConfiguration–Search on Index

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

Leave a Reply