Troubleshooting ConfigMgr 2012 Client Migration using Powershell (Part 5)

In this post we’ll look at troubleshooting WMI errors.  Fixing every potential WMI issue is beyond the scope of this blog series, but what we can do it run the WMIDiag utility on the client machine, and this is very helpful to diagnose potential issues with WMI.  The report generated by WMIDiag contains advice on how to resolve the WMI errors it finds.

If ConfigMgr cannot install the client due to a WMI error, this should be reported in the CCM.log on the Site Server. Check there to find the exact error code. The error code may or may not indicate an actual WMI issue, as described in the WMIDiag documentation:

0x800410xx and 0x800440xx are WMI errors. These error codes mean that a specific WMI operation failed. This could be due insufficient privileges to perform the WMI requested operation; due to the nature of the request itself (for example, no WMI rights, bad WQL query); or due to a WMI infrastructure issue, such as CIM or WMI DCOM registration preventing a provider from being loaded.

0x8007xxxx are Win32 errors, not WMI errors. WMI may return these types of error due to an external failure (for example, DCOM security).

0x80040xxx are pure DCOM errors, not WMI errors. WMI may return these types of error due to an external failure (for example DCOM configuration).

0x80005xxx are ADSI errors (LDAP), not WMI errors. WMI may return these types of errors due to an external failure, such as an Active Directory access failure when using the WMI Active Directory providers.

If a true WMI error is suspected, we can run WMIDiag on the machine using Powershell.

Prepare the WMIDiag Files

Download WMIDiag from Microsoft and place the 3 files on a network share.  Since WMIDiag must be run locally, the script will copy the WMIDiag.vbs to the remote machine and start it.

Run the Powershell Script

Run the Powershell Script below entering the following variables:
$ComputerName = the name of the remote computer to run WMIDiag on
$CMTrace = The path to the CMTrace utility used for viewing the resulting log file.
$WMIDiagVBS = Enter the path to the WMIDiag.vbs on the file share
$ClientLogs = Enter a remote fileshare to copy the client logs to

The script will take some time to complete. When the WMIDiag has finished, it creates 3 files on the client:

  • Text file. This contains a summary of the health of the WMI.
  • Log file. This contains the full output of the WMIDiag tool.
  • CSV file. This contains a summary that can be imported into the master WMIDiag.csv file to view statistics for multiple machines

The script will copy these files from the client to the file share, then open the text file using the CMTrace utility for easy viewing.

The Powershell Script

This script will run WMIDiag on a remote machine and opens the text report with CMTrace to review the results.
$ComputerName = "DB-MyLaptop"
$CMTrace = "C:\Program Files (x86)\ConfigMgr 2012 Toolkit R2\ClientTools" # Path to CMTrace.exe on local computer

$WMIDiagFolder = "\\$ComputerName\c$\WMIDiag"
$WMIDiagLogsFolder = "\\$ComputerName\c$\WMIDiag\Logs"
$WMIDiagVBS = "\\PS1sccm-01\RemoteFiles\WMIDiag\WMIDiag.vbs"
$ClientLogs = "\\PS1sccm-01\ClientLogs\$computername"

# Test if WMIDiag and Logs directories exist, if not create them
Write-Host "Creating local directories if needed..."
If (Test-Path $WMIDiagFolder)
New-Item -Path $WMIDiagFolder -ItemType Directory | Out-Null

If (Test-Path $WMIDiagLogsFolder)
New-Item -Path $WMIDiagLogsFolder -ItemType Directory | Out-Null

# Copy WMIDiag.vbs to local machine and run it

Copy-item $WMIDiagVBS $WMIDiagFolder
write-host "Running WMIDiag on $Computername. This will take some time!" -ForegroundColor Yellow
Invoke-Command -ComputerName $computername -ScriptBlock `
{ `
cscript c:\WMIDiag\WMIDiag.vbs Silent NoEcho LogFilePath=C:\WMIDiag\Logs `

# Copy the resulting files to a server location

If (Test-Path $ClientLogs)
New-item $ClientLogs -itemtype Directory | Out-Null
Write-Host "Copying logs to server..."
copy-item $WMIDiagLogsFolder $ClientLogs -recurse -ErrorAction SilentlyContinue

# Open text report

Write-Host "Opening text report.."
$Item = Get-Item -Path "$ClientLogs\Logs\*.txt" | Select Name
$Item = $Item.Name
& "$CMTrace\CMTrace.exe" "$ClientLogs\Logs\$Item"

Repairing WMI

Some advise to delete and recreate the WMI repository, and this will generally fix a WMI issue, however it can affect other applications, so it’s recommended to be a last resort.  A more friendlier way to repair the WMI is to use Roger Zander’s SCCM Client Center, which has a Repair WMI option, and in the 2012 version it works even when you cannot connect to WMI on the machine because it uses winRM.

Here’s some useful articles for WMI repairs:

That’s it for now! Hopefully these posts will help you troubleshoot and fix many of the common issues that occur with ConfigMgr client upgrades.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s