Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get NDIS Version(s)?

Tags:

c#

vb.net

ndis

I know that I could use Windows PowerShell

Get-netadapter|select Name, ndisversion

to pipe the results out to a text file, and parse the data from there, but that's sort of hacky. I was wondering if there's a way to get the same info using something more direct? i.e. WMI or a Framework class, etc.? I've Googled, but came up empty-handed.

like image 848
J. Scott Elblein Avatar asked May 08 '26 06:05

J. Scott Elblein


1 Answers

All the NetAdapter powershell cmdlets are thin wrappers over WMI objects. So you can indeed use the Microsoft.Management.Infrastructure namespace directly.

In this case, you'd enumerate instances of root\standardcimv2\MSFT_NetAdapter to look at their Name and DriverMajorNdisVersion fields.

This isn't a complete tutorial on the MI APIs, but here's a pseudocode sketch of the idea:

var session = CimSession.Create(. . .);
foreach (var instance in session.EnumerateInstances(@"root\standardcimv2", "MSFT_NetAdapter")) {
    var name = instance.CimInstanceProperties["Name"].Value as string;
    var major = instance.CimInstanceProperties["DriverMajorNdisVersion"].Value as byte;
    WriteLine($"{name}: {major}.{minor}");
}
like image 104
Jeffrey Tippet Avatar answered May 10 '26 12:05

Jeffrey Tippet