Useful WMI Command
WMI, which stands for Windows Management Instrumentation, is a powerful tool that allows administrators to manage Windows systems both locally and remotely. It provides a deeper level of information and control than standard PowerShell commands. For instance, while the Get-Service
command in PowerShell can retrieve service details, WMI can provide even more properties related to those services.

Here are a collection of my favorite WMI Commands
WMI Command: Retrieve All Properties of Services
<Get-WmiObject -Class Win32_Service | Select-Object *
This WMI command fetches all the properties of services running on the system using the Win32_Service
class.
WMI Command: Determine the Last Boot Up Time
$os = gwmi win32_operatingsystem $os.ConvertToDateTime($os.LastBootUpTime)
The above command retrieves the last boot up time of the operating system and converts it to a readable date-time format. For example, it might return “24 October 2017 09:37:51”.
To get a shorter version of the date:
$os.ConvertToDateTime($os.LastBootUpTime).toshortdatestring()
This will return a concise date format, like “24/10/2017”.
List Services that Start Automatically and are Running
Get-WmiObject -Class Win32_Service -Filter "state = 'running' and startmode = 'auto'" | Select-Object name, startmode, description | Format-table -AutoSize
This command lists all services that are set to start automatically and are currently running. It displays their names, start modes, and descriptions in a table format.
Retrieve BIOS Information
Get-WmiObject -Class Win32_Bios
This command fetches information about the system’s BIOS using the Win32_Bios
class.
Obtain Computer Information
Get-WmiObject Win32_Computersystem | Format-List Name, manufacturer, model, SystemType
This command provides details about the computer system, such as its name, manufacturer, model, and system type.
Get Video Card Information
Get-WmiObject Win32_VideoController
This command retrieves basic information about the video card using the Win32_VideoController
class.
For a more detailed report on the video card:
$ComputerName = "localhost"
foreach ($Computer in $ComputerName)
{
$ComputerVideoCard = Get-WmiObject Win32_VideoController -ComputerName $Computer
$Output = New-Object -TypeName PSObject
Foreach ($Card in $ComputerVideoCard)
{
$Output | Add-Member NoteProperty "$($Card.DeviceID)_Name" $Card.Name
$Output | Add-Member NoteProperty "$($Card.DeviceID)_Vendor" $Card.AdapterCompatibility
$Output | Add-Member NoteProperty "$($Card.DeviceID)_PNPDeviceID" $Card.PNPDeviceID
$Output | Add-Member NoteProperty "$($Card.DeviceID)_DriverVersion" $Card.DriverVersion
$Output | Add-Member NoteProperty "$($Card.DeviceID)_VideoMode" $Card.VideoModeDescription
}
$Output
}
This script fetches detailed information about the video card, such as its name, vendor, PNP device ID, driver version, and video mode description.
Recent Comments