Useful WMI Command

WMI, which stands for Windows Management Instrumentation, is a powerful tool allowing administrators to manage Windows systems 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 is a collection of my favorite WMI Commands

WMI Command: Retrieve All Properties of Services

PowerShell
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

PowerShell
$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:

PowerShell
$os.ConvertToDateTime($os.LastBootUpTime).toshortdatestring()

This will return a concise date format, like “24/10/2017”.

List Services that Start Automatically and are Running

PowerShell
Get-WmiObject -Class Win32_Service -Filter "state = 'running' and startmode = 'auto'" | Select-Object name, startmode, description | Format-table -AutoSize

This command lists all services set to start automatically and are currently running. It displays their names, start modes, and descriptions in a table format.

Retrieve BIOS Information

PowerShell
Get-WmiObject -Class Win32_Bios

This command fetches information about the system’s BIOS using the Win32_Bios class.

Obtain Computer Information

PowerShell
Get-WmiObject Win32_Computersystem | Format-List Name, manufacturer, model, SystemType

This command details the computer system, such as its name, manufacturer, model, and system type.

Get Video Card Information

PowerShell
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:

PowerShell
$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.

Elsewhere On TurboGeek:  PowerShell OneLiners for Active Directory

Richard.Bailey

Richard Bailey, a seasoned tech enthusiast, combines a passion for innovation with a knack for simplifying complex concepts. With over a decade in the industry, he's pioneered transformative solutions, blending creativity with technical prowess. An avid writer, Richard's articles resonate with readers, offering insightful perspectives that bridge the gap between technology and everyday life. His commitment to excellence and tireless pursuit of knowledge continues to inspire and shape the tech landscape.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate ยป