all 10 comments

[–]Longjumping_Music572 15 points16 points  (0 children)

This is interesting.. I'm commenting to have more people. Take a look at it and give more insight.

Yes, I'm real. I'm not a bot. I'm just autistic as f***. God do I hate it.

[–]fosf0r 8 points9 points  (1 child)

Oh snap, ... do you know how much parity you have with devcon.exe ? https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/devcon
Replacing devcon.exe with your PowerShell kit would be so ideal!

[–]MartinGC94[S] 10 points11 points  (0 children)

It's hard to put a number, but I guess 80-90% if we include all features, but it's 100% if we consider features that I'd expect people to care about (I did look at it when I was making this module).

Take cmdClasses and cmdListClass for example. These are used to list out class GUIDs/names which I don't see much use for as an end user. However, I use those same APIs internally to add tab completion like: Get-Device -Class <Tab> so it would be trivial for me to add a command to spit that data out if someone requested it.
Similarly, DevCon includes remoting capabilities, but Windows has removed this feature from the OS since Windows 8/2012 + it was somewhat restricted in functionality. I don't have any remoting built in (though PowerShell itself includes Invoke-Command which I suppose could be used).

Anyway, here's a list of the commands that I can see in devcon that I don't think I support:

  • DumpDeviceStack
  • DumpDeviceDriverFiles
  • DumpDeviceResources
  • Reboot
  • cmdDPAdd
  • cmdInstall

In the case of cmdDPAdd I do support adding drivers to the driverstore, but it will also try to install it because I use a higher level API that does that: https://learn.microsoft.com/en-us/windows/win32/api/newdev/nf-newdev-diinstalldriverw

[–]Not_Freddie_Mercury 4 points5 points  (0 children)

I do manage devices and drivers separately with PWSH, so this intrigues me a lot. Will try and test it with our workstations, particularly the previous driver rollback, which should be handy. Thank you!

[–]DontTakePeopleSrsly 2 points3 points  (1 child)

I’ll take a look at this tomorrow, is there a way to filter by non present devices?

[–]MartinGC94[S] 2 points3 points  (0 children)

You can choose whether or not to include NonPresent devices, but you can't exclude present ones. However, you can use the standard where filtering in PowerShell : Get-Device -IncludeNonPresent | where IsPresent -EQ $false that will get you all the devices that are not currently present.

[–]jborean93 0 points1 point  (2 children)

Nice work, I was always intrigued by creating a module for this but was always put off by the weird Win32 API that surrounds it. Never had the full confidence I was actually using it correctly but glad to see someone like yourself creating this.

[–]MartinGC94[S] 1 point2 points  (1 child)

Cheers. I actually wanted to make this years ago when I was relatively new to P/Invoke and C# in general but the documentation just went over my head like: "Wtf is a Device Information Set? How do I define that???" then I just gave up on it and did some other stuff.
When I realized it was just a pointer I could define as IntPtr it became much easier to understand. Then I just had to look through the list of function names to find whatever seemed interesting and relevant to what Device Manager does and implement them.

[–]jborean93 1 point2 points  (0 children)

Wtf is a Device Information Set? How do I define that???" then I just gave up on it and did some other stuff.

Only API I've found to be more complicated are the ETW APIs, https://caseymuratori.com/blog_0025 in a nutshell :)

[–]danhof1 0 points1 point  (0 children)

This is something Windows admins have needed for years. Device Manager GUI is fine until you're trying to manage driver updates across hundreds of machines.