Jean Lalonde Support Forum

Full Version: [Tools-Win] WMI and QAP(favourites) Part 2
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
NOTE!
If you want to browse the WMI information I recommend SimpleWMIView by NirSoft.

If you don't have PS 7 installed, replace "pwsh" with "powershell".

Example
This query asks WMI about some basic info about the physical disk drives in the system:
Get-CimInstance -ClassName Win32_DiskDrive | Select-Object Model,SerialNumber,FirmwareRevision,Status

You can run this in a PowerShell window as is, but to run it as favourite we have to add some stuff:
pwsh -NoExit -Command "Get-CimInstance -ClassName Win32_DiskDrive | Select-Object Model,SerialNumber,FirmwareRevision,Status"

Favourite
UserVar:
{pwshopt}=-NoExit -Command "Get-CimInstance -ClassName
Type: Application

Basic Settings, Application: pwsh
Adv. Settings, Parameters: -NoExit -Command "Get-CimInstance -ClassName Win32_DiskDrive | Select-Object Model,SerialNumber,FirmwareRevision,Status"

Or, we can clean up a little with a UserVar:

Basic Settings, Application: pwsh
Adv. Settings, Parameters: {pwshopt} Win32_DiskDrive | Select-Object Model,SerialNumber,FirmwareRevision,Status"
(Don't forget the qoutation mark at the end)

Other WMI classes that might be interesting
Win32_PhysicalMemory | Select-Object BankLabel,Capacity,ConfiguredClockSpeed,DeviceLocator,Manufacturer,PartNumber,SerialNumber,Speed
Win32_LogicalDisk | Select-Object DeviceID, FileSystem, ProviderName, VolumeName,VolumeSerialNumber
Win32_NetworkAdapter | Select-Object DeviceID, Name, MACAddress
Win32_NetworkAdapterConfiguration | Select-Object Index, Description, MACAddress, IPAddress, DefaultIPGateway
(Use Select-Object * to show all objects in that class)
Win32_BaseBoard | Select-Object *
Win32_BIOS | Select-Object *
Win32_ComputerSystem | Select-Object *
Win32_Service | Select-Object *
Win32_Processor | Select-Object *

In the last part (part 3) we'll look at very simple script to do some more stuff.
Now, go forth and play with WMI! Smile

Regards,
joeNOR
(EDIT: Fixed error with Select-Object)
Didn't cover this, but it is also possible to do queries based on content of an object, example:
Code:
gcim -Query "SELECT * FROM Win32_NetworkAdapter WHERE PhysicalAdapter = 'True'" | Select-Object Name,MACAddress,NetConnectionID,DeviceID | Format-Table -Wrap -AutoSize

.....or use a filter:
Code:
gcim -ClassName Win32_NetworkAdapter -Filter "PhysicalAdapter = 'True'" | Select-Object Name,MACAddress,NetConnectionID,DeviceID | Format-Table -Wrap -AutoSize