Useful WMI Commands
Reading Time: < 1 minute
Search WMIObjects
Get-WmiObject -Namespace Root\cimv2 -list | where {$_.name -like '*disk*'}
Awesome WMI explorer tool can be found here – https://powershell.org/2013/03/08/wmi-explorer-from-the-powershell-guy/
WMI contains more properties that Standard Powershell commands eg. Get-Service
Get-WmiObject -Class Win32_Service | Select-Object *
WMI Win32_operatingsystem last boot uptime conversion
$os = gwmi win32_operatingsystem
$os.ConvertToDateTime($os.LastBootUpTime)
EG -24 October 2017 09:37:51
Convert to shortstring
$os.ConvertToDateTime($os.LastBootUpTime).toshortdatestring()
EG – 24/10/2017
Get list of Services that start automatically
Get-WmiObject -Class Win32_Service -Filter "state = 'running' and startmode = 'auto'" | Select-Object name, startmode, description | Format-table -AutoSize
Get BIOS information
Get-WmiObject -Class Win32_Bios
Get Computer information
Get-WmiObject Win32_Computersystem | Format-List Name, manufacturer, model, SystemType
$computerVideo = Get-WmiObject Win32_VideoController -ComputerName localhost
write-host "System Information for: " $computerSystem.Name -BackgroundColor DarkCyan
"-------------------------------------------------------"
"Video Info: " + $computerVideo.description
""
"-------------------------------------------------------"
Get Video Card information
Get-WmiObject Win32_VideoController
Get Detailed information
$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)_Description" $Card.Description #Probably not needed. Seems to just echo the name. Left here in case I'm wrong!
$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
}
Recent Comments