Thursday, 2 February 2017

Rebuilding and reinstalling the WMI Repository

Rebuilding and reinstalling the WMI Repository

If you experience behavior when using WMI, such as application errors or scripts that used to work are no longer working, you may have a corrupted WMI repository. To fix a corrupted WMI repository, use these steps:

Windows XP and Windows Vista

Click Start -> Run and type CMD.EXE
Note: In Windows Vista, you need to open an elevated Command Prompt window. To do so, click Start, click All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.

Type this command and press Enter:

net stop winmgmt

Using Windows Explorer, rename the folder %windir%\System32\Wbem\Repository. (For example, %windir%\System32\Wbem\Repository_bad). %windir% represents the path to the Windows directory, which is typically C:\Windows.

Switch to Command Prompt window, and type the following and press ENTER after each line:
net start winmgmt
EXIT

For Windows XP Service Pack 2 and Service Pack 3

Click StartRun and type the following command:
rundll32 wbemupgd, UpgradeRepository

This command is used to detect and repair a corrupted WMI Repository. The results are stored in the setup.log (%windir%\system32\wbem\logs\setup.log) file.

For Windows Vista

Open an elevated Command Prompt window. To do so, click Start, click All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.
Type the following command:

winmgmt /salvagerepository

The above command Performs a consistency check on the WMI repository, and if an inconsistency is detected, rebuilds the repository. The content of the inconsistent repository is merged into the rebuilt repository, if it can be read.

For Windows Server 2003

Use the following command to detect and repair a corrupted WMI Repository:

rundll32 wbemupgd, RepairWMISetup

Re-registering the WMI components 

The .DLL and .EXE files used by WMI are located in %windir%\system32\wbem. You might need to re-register all the .DLL and .EXE files in this directory. If you are running a 64-bit system you might also need to check for .DLLs and .EXE files in %windir%\sysWOW64\wbem.

To re-register the WMI components, run the following commands at the command prompt:
  • CD %windir%\system32\wbem
  • for /f %s in ('dir /b /s *.dll') do regsvr32 /s %s
  • for /f %s in ('dir /b *.mof') do mofcomp %s 
Registering WMI Service itself

Open the command console, type "net stop winmgmt". When you get the warning that other services need to be stopped type 'Y' and continue.

Open 'My Computer' and then go to the folder '%SystemRoot%\System32\WBEM\Repository' and delete that folder.

Reboot your system.

After you login, open the command console, and type the following commands in order: 
 

winmgmt /clearadap
winmgmt /kill
winmgmt /unregserver
winmgmt /regserver
winmgmt /resyncperf
Note: If this doesn't fix the problem, you need to try reinstalling Comprehensive rebuild method. 

Comprehensive rebuild method 

Important note: If you've installed a Service Pack, you need to insert your Windows XP CD with Service Pack integration (called as the Slipstreamed Windows XP CD). If you don't have one, you may point to the %Windir%\ServicePackFiles\i386 folder for a recent version of the system files required during WMI repair. Or you may create a slipstreamed Windows XP CD and insert it when prompted.


Click StartRun and type the following command, and press ENTER:

rundll32.exe setupapi,InstallHinfSection WBEM 132 %windir%\inf\wbemoc.inf

Insert your Windows XP CD into the drive when prompted. Repair process should take few minutes to complete. Then restart Windows for the changes to take effect.

Note that none of the above two methods restore the missing files related to Windows Management Instrumentation (WMI). So, below is a comprehensive repair procedure that restores all the missing WMI modules. In case of missing WMI modules, you may use the following method.

Repair WMI using BAT File:

Most of the WMI problems can be solved by rebuilding the WMI Repository, re-registering the WMI components. To automate this, you could create a BAT file. Copy the following lines to a text file and save it with .BAT extension and run it to fix common WMI issues. 
net stop winmgmt /y
%SYSTEMDRIVE%
CD %windir%\system32\wbem
rd /S /Q repository
net start winmgmt
for /f %%s in ('dir /b /s *.dll') do regsvr32 /s %%s
for /f %%s in ('dir /b *.mof') do mofcomp %%s
Share:

Wednesday, 1 February 2017

SCCM 2007 Client Agent Installation Failure

Tag Archives: SCCM 2007 Client

SCCM 2007 CLIENT AGENT INSTALLATION FAILURE

This post documents my experiences with:
  • SCCM 2007 client installation failure
  • SCCM 2007 SMS Host Agent service will not start
  • SCCM 2007 client agents that stop working.
The post assumes the SCCM 2007 infrastructure is in-place and functional and the failures being experienced are not down to SCCM 2007 server configuration issues or network connectivity issues etc., they are just failures relating to individual client machine issues.
The Basics
  • Is the SMS Agent Host service running on the machine? If not start it.
  • You can run ccmsetup /uninstall and then re-install the client using your favoured method.
Install or Repair the Agent from the SCCM 2007 Console
  • Initiate a client push installation from the SCCM 2007 Management console to the target machine, (whether it is a new client or an existing client that is faulty) – ensuring the Repair option is selected in the Client Push Wizard.
  • Access the CCMSetup folder (depending on the OS this could be under the WindowsSystem32 or SysWOW64 folder) on the target machine and review the ClientMSI and the CCMSetup logs. If the installation was successful happy days, if not are there any clues in the logs why the install failed?
WMI – Rebuild the Repository.
The root of most SCCM client problems. The classic fix:
  • Set the WMI service to Disabled.
  • Stop the WMI service.
  • Take a backup copy of everything under the C:\Windows\System32\WBEM\Repository folder.
  • Delete everything under the C:\Windows\System32\WBEM\Repository folder.
  • Set the WMI service to Automatic and restart the service.
WMI Again – Corrupt Files
  • Set the WMI service to Disabled.
  • Stop the WMI service.
  • Take a copy of all the files under the C:\Windows\System32\WBEM folder.
  • Access a similar machine to the machine with the problem that has a working SCCM 2007 client.
  • Copy all the files (not the folders) from the C:\Windows\System32\WBEM folder and overwrite the equivalent files on the problematic machine.
  • Set the WMI service to Automatic and restart the computer.
WMI Yet Again – System Path Variable
  • Ensure the System Path Variable includes either %SystemRoot%\System32\WBEM or the specific path to the WBEM folder, e.g. C:\Windows\System32\WBEM.
  • If you need to add the entry restart the WMI and SMS Agent Host services.
SMS Certificates
  • Open the Certificates MMC for the Computer account of the affected machine.
  • Navigate to the SMS node in the Certificates console.
  • Check the expiration dates of the two SMS certificates. The year part of the date should about 100 years in the future, based on the date of the client install. If the year part of the date looks really strange (I have seen the year part as 7803, 9265) delete the certificates.
  • Restart (or most likely just start) the SMS Agent Host Service on the client machine.
Duplicate Machine Names in SCCM database
Because of the way we provision new and replacement machines where I work I often end up with duplicate machine names in the SCCM 2007 database/console. To remove the duplicates:
  • Create a query-based Collection to highlight the duplicate machine names (query to follow).
  • Ensure the ResourceID field is visible in the SCCM 2007 console.
  • Sort on the Machine Name field.
  • Delete the instance of the duplicate machine name that has the lowest ResourceID number.
  • Restart the SMS Host Agent service on the remaining instance.
SMSCFG.ini
This has only worked once for me and I can’t remember the exact circumstance when I tried it (might have been a duplicate GUID but not 100% sure).
  • Delete the C:\Windows\SMSCFG.ini and restart the SMS Agent Host service.
How do I know if an Existing Client is Faulty?
I use a number of query-based SCCM Collections to highlight either potentially faulty or missing SCCM 2007 client agents.
To follow.
How do I know an SCCM 2007 Agent is Active Again?
It can take a bit of time for current data about a “fixed” machine to appear in the SCCM 2007 console.  My quick check is just to look at the date/time stamp for the files in the CCMLogs folder on the client. If there is lots recent activity in lots of logs (maybe 20 or so logs have a very current time stamp) then it is likely the client is fixed.
Share:

SCCM Client – Manual install and uninstall

SCCM 2007 CLIENT AGENT INSTALLATION FAILURE

This post documents my experiences with:
  • SCCM 2007 client installation failure
  • SCCM 2007 SMS Host Agent service will not start
  • SCCM 2007 client agents that stop working.
The post assumes the SCCM 2007 infrastructure is in-place and functional and the failures being experienced are not down to SCCM 2007 server configuration issues or network connectivity issues etc., they are just failures relating to individual client machine issues.
The Basics
  • Is the SMS Agent Host service running on the machine? If not start it.
  • You can run ccmsetup /uninstall and then re-install the client using your favoured method.
Install or Repair the Agent from the SCCM 2007 Console
  • Initiate a client push installation from the SCCM 2007 Management console to the target machine, (whether it is a new client or an existing client that is faulty) – ensuring the Repair option is selected in the Client Push Wizard.
  • Access the CCMSetup folder (depending on the OS this could be under the WindowsSystem32 or SysWOW64 folder) on the target machine and review the ClientMSI and the CCMSetup logs. If the installation was successful happy days, if not are there any clues in the logs why the install failed?
WMI – Rebuild the Repository.
The root of most SCCM client problems. The classic fix:
  • Set the WMI service to Disabled.
  • Stop the WMI service.
  • Take a backup copy of everything under the C:\Windows\System32\WBEM\Repository folder.
  • Delete everything under the C:\Windows\System32\WBEM\Repository folder.
  • Set the WMI service to Automatic and restart the service.
WMI Again – Corrupt Files
  • Set the WMI service to Disabled.
  • Stop the WMI service.
  • Take a copy of all the files under the C:\Windows\System32\WBEM folder.
  • Access a similar machine to the machine with the problem that has a working SCCM 2007 client.
  • Copy all the files (not the folders) from the C:\Windows\System32\WBEM folder and overwrite the equivalent files on the problematic machine.
  • Set the WMI service to Automatic and restart the computer.
WMI Yet Again – System Path Variable
  • Ensure the System Path Variable includes either %SystemRoot%\System32\WBEM or the specific path to the WBEM folder, e.g. C:\Windows\System32\WBEM.
  • If you need to add the entry restart the WMI and SMS Agent Host services.
SMS Certificates
  • Open the Certificates MMC for the Computer account of the affected machine.
  • Navigate to the SMS node in the Certificates console.
  • Check the expiration dates of the two SMS certificates. The year part of the date should about 100 years in the future, based on the date of the client install. If the year part of the date looks really strange (I have seen the year part as 7803, 9265) delete the certificates.
  • Restart (or most likely just start) the SMS Agent Host Service on the client machine.
Duplicate Machine Names in SCCM database
Because of the way we provision new and replacement machines where I work I often end up with duplicate machine names in the SCCM 2007 database/console. To remove the duplicates:
  • Create a query-based Collection to highlight the duplicate machine names (query to follow).
  • Ensure the ResourceID field is visible in the SCCM 2007 console.
  • Sort on the Machine Name field.
  • Delete the instance of the duplicate machine name that has the lowest ResourceID number.
  • Restart the SMS Host Agent service on the remaining instance.
SMSCFG.ini
This has only worked once for me and I can’t remember the exact circumstance when I tried it (might have been a duplicate GUID but not 100% sure).
  • Delete the C:\Windows\SMSCFG.ini and restart the SMS Agent Host service.
How do I know if an Existing Client is Faulty?
I use a number of query-based SCCM Collections to highlight either potentially faulty or missing SCCM 2007 client agents.
To follow.
How do I know an SCCM 2007 Agent is Active Again?
It can take a bit of time for current data about a “fixed” machine to appear in the SCCM 2007 console.  My quick check is just to look at the date/time stamp for the files in the CCMLogs folder on the client. If there is lots recent activity in lots of logs (maybe 20 or so logs have a very current time stamp) then it is likely the client is fixed.
Share:

Repair SCCM client remotely


Description:

This is a basic vbscript called by windows cscript to repair config manager clients. CM Clients can become broken for a number of reasons in enterprise environments. The  script has been tested on 2007 and should work on 2012 too. This script can be easily modified to retrieve hosts from a text file e.g computers.txt if you’re targeting a number of broken clients.

 Usage:

E.g  cscript scriptname.vbs computername



'Repair SCCM Client
'------------------------------------------------------------

Option Explicit
On Error Resume Next

Dim sComputer, sSCCMClient

If WScript.Arguments.Count = 0 Then
sComputer = InputBox("Enter computer name to repair")
Else
sComputer = WScript.Arguments(0)
End If

Set sSCCMClient = GetObject("winmgmts://" & sComputer & "/Root/Ccm:SMS_Client")

If Err <> 0 Then
MsgBox "Error:" & "(" & Err.Number & ")" & vbCrLf & Err.Description
Else
sSCCMClient.RepairClient
MsgBox ("Repair started for " & UCase(sComputer))
End If

WScript.Quit

Share:

Tuesday, 17 January 2017

Client uninstallation script

@echo off
Echo Please Wait. Currently Uninstalling Microsoft SCCM 2007 Client
IF EXIST C:\Windows\System32\ccmsetup\ccmsetup.exe GOTO REMOVE
GOTO END
:REMOVE
c:\Windows\System32\ccmsetup\ccmsetup.exe /uninstall
RD /S /Q C:\Windows\System32\ccmsetup
:END

Share:

Monday, 19 December 2016

Clients Active to inactive resolving

Is WMI functioning on the machine that is inactive? Whenever I get an inactive machine I had to wipe and reset the WMI repositories.

I find the little script in this link fixes 99% of all my problems. Doesn't happen often but this solves it for me when it does.

http://blogs.technet.com/b/configmgrteam/archive/2009/05/08/wmi-troubleshooting-tips.aspx

Share: