How to Use WMIC for Remote System Inventory: Querying OS and Installed Programs Across Domain-Joined Machines


12 views

When attempting remote WMIC queries across domain-joined systems, several technical hurdles frequently emerge:

// Common error you might encounter
wmic /node:192.168.1.100 OS get name,vendor >> output.txt
// Returns: Node - 192.168.1.100 Error: Description = Invalid query

The key is proper credential formatting and global switch placement:

// Correct domain authentication syntax
wmic /node:"targetPC" /user:"DOMAIN\administrator" /password:"P@ssw0rd" /namespace:\\root\cimv2 OS get Caption,CSDVersion,OSArchitecture /format:csv >> C:\inventory.csv

For comprehensive software inventory across multiple machines:

// Batch script for multi-machine inventory
@echo off
set DOMAIN=yourdomain.local
set USER=adminuser
set PASS=AdminPass123

for /f %%i in (pclist.txt) do (
  wmic /node:"%%i" /user:"%DOMAIN%\%USER%" /password:"%PASS%" product get name,version,vendor /format:csv >> \\server\share\inventory_%%i.csv
  wmic /node:"%%i" /user:"%DOMAIN%\%USER%" /password:"%PASS%" OS get Caption,Version /format:csv >> \\server\share\osinfo_%%i.csv
)

Essential pre-requisites for successful remote WMI queries:

  • Windows Firewall: Enable "Windows Management Instrumentation (WMI-In)" rule
  • DCOM permissions: Configure via Component Services (dcomcnfg)
  • Group Policy: Computer Configuration > Administrative Templates > Windows Components > Windows Remote Management > Allow Automatic Configuration
  • WMI namespace security: Requires "Enable Account" and "Remote Enable" permissions

For more robust enterprise inventory:

# PowerShell equivalent with error handling
$cred = Get-Credential
$computers = Get-Content "C:\pclist.txt"

foreach ($pc in $computers) {
  try {
    $os = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $pc -Credential $cred -ErrorAction Stop
    $software = Get-WmiObject -Class Win32_Product -ComputerName $pc -Credential $cred
    
    [PSCustomObject]@{
      ComputerName = $pc
      OSName = $os.Caption
      OSVersion = $os.Version
      InstallDate = $os.InstallDate
      SoftwareCount = $software.Count
    } | Export-Csv -Path "C:\inventory.csv" -Append -NoTypeInformation
  }
  catch {
    Write-Warning "Failed to query $pc : $_"
  }
}

Diagnostic commands when queries fail:

// Test basic WMI connectivity
wmic /node:"targetPC" /user:"DOMAIN\admin" /password:"pass" path Win32_ComputerSystem get Name

// Check WMI service status remotely
sc \\targetPC query winmgmt

// Verify DCOM permissions
dcomcnfg /computer targetPC

When attempting to gather system information across a Windows domain, many administrators encounter authentication and syntax hurdles with WMIC. The common error "Invalid query" typically indicates either permission issues or incorrect command structure.

The correct syntax for remote WMIC queries requires careful parameter ordering:

wmic /node:"192.168.1.100" /user:"DOMAIN\administrator" /password:"P@ssw0rd" OS get name,version,manufacturer /format:csv > C:\output.csv

For enumerating installed programs across all domain machines, use this PowerShell-enhanced approach:

$computers = Get-ADComputer -Filter * | Select -ExpandProperty Name
foreach ($pc in $computers) {
    wmic /node:$pc /user:"DOMAIN\admin" /password:"P@ssw0rd" product get name,vendor,version /format:csv | Out-File "C:\inventory\$pc-programs.csv"
}
  • Firewall Blocking: Ensure TCP port 135 and RPC ports are open
  • UAC Restrictions: Add registry key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\LocalAccountTokenFilterPolicy set to 1
  • Time Synchronization: Kerberos requires time sync within 5 minutes

For environments where WMIC fails, consider these alternatives:

# PowerShell Remoting alternative
Invoke-Command -ComputerName PC01 -ScriptBlock { Get-WmiObject Win32_Product } -Credential DOMAIN\admin

Always follow these security best practices:

  • Use dedicated service accounts instead of domain admin credentials
  • Implement Just-in-Time administrative access
  • Consider using LAPS (Local Administrator Password Solution)