【备忘】修复SCCM客户端

1. 把相关修复文件复制到有问题的电脑的本地硬盘,比如C:\Temp

2. 运行 Uninstall.cmd

@rem Stop all SCCM Processes
net stop ccmexec
taskkill /F /FI "SERVICES eq ccmexec"
taskkill /F /IM ccmexec.exe
taskkill /F /IM ccmeval.exe
taskkill /F /IM ccmsetup.exe
taskkill /F /IM ccmrepair.exe
taskkill /F /IM CmRcService.exe
taskkill /F /IM SCNotification.exe
taskkill /F /IM msiexec.exe
taskkill /F /IM ccmrestart.exe
taskkill /F /IM Ccm32BitLauncher

@rem Set WMI to run in standalonehost
C:\Windows\System32\wbem\WinMgmt.exe /standalonehost

@rem Set the Windows Modules Installer service to manual start
sc config TrustedInstaller start= demand

@rem Make sure C:\Windows\Installer exists
md C:\Windows\Installer

%~dp0ccmsetup.exe /uninstall

@rem Delete .SDF and .SQLCE files
del /q C:\Windows\CCM\*.sdf
del /q C:\Windows\CCM\*.sqlce

@rem Uninstall Silverlight
@rem %SystemRoot%\System32\wbem\WMIC.exe product where caption='Microsoft Silverlight' call uninstall

@rem Kill any BITS transfers that might be in error.
%~dp0tools\PsExec.exe -s -accepteula bitsadmin.exe /reset /ALLUSERS

@rem delete SMS certificates
%~dp0tools\ccmdelcert.exe
PowerShell.exe -NoProfile -Command "Get-ChildItem Cert:\LocalMachine\SMS | Where-Object {$_.FriendlyName -like 'SMS*' } | Remove-Item"
%~dp0tools\setacl.exe -on "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\19*" -ot file -rec cont_obj -actn ace -ace "n:administrators;m:grant;p:full"
PowerShell.exe -NoProfile -Command "Get-ChildItem -Path 'C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\' | Where-Object {$_.Name -like '19*' } | Remove-Item -Force"

If exist c:\Windows\SMSCFG.INI del /q c:\Windows\SMSCFG.INI

@Rem Delete Client Registry Keys
REG DELETE HKLM\SOFTWARE\Microsoft\CCMSetup /f
REG DELETE HKLM\SOFTWARE\Microsoft\SMS /f
REG DELETE HKLM\SOFTWARE\Wow6432Node\Microsoft\CCM /f
REG DELETE HKLM\SOFTWARE\Wow6432Node\Microsoft\CCMSetup /f
REG DELETE HKLM\SOFTWARE\Wow6432Node\Microsoft\SMS /f

C:\Windows\System32\takeown.exe /f C:\Windows\CCM\* /R /A
C:\Windows\System32\takeown.exe /f C:\Windows\ccmsetup\* /R /A
%~dp0tools\setacl.exe -on "C:\Windows\CCM\*" -ot file -rec cont_obj -actn ace -ace "n:administrators;m:grant;p:full"
%~dp0tools\setacl.exe -on "C:\Windows\ccmsetup\*" -ot file -rec cont_obj -actn ace -ace "n:administrators;m:grant;p:full"

pause

3. 运行 C:\Temp\Client\tools\ccmclean.exe

4. 删除所有CCM开头的文件夹。

:操作过程中,发现CCM目录下会有一个 SensorFramework子目录无法被删除,做删除的时候也没报错,但就是删除不掉。另外,目录里会有几个c4eaa67d开头的文件。

删除办法:运行 logman -ets 命令,列出当前活动的会话,然后运行 logman stop <会话名> -ets 来停止那几个 c4eaa67d开头的会话,停止后SensorFramework目录里的文件会自动删除,然后就可以删除 CCM目录了。

5. In case, if a folder is stuck and can’t be removed run the following:

sc queryex winmgmt

taskkill /f /pid  <<上一个命令得到的 PID >>

6.  检查确认 C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\ 目录里,开头是19*的 "RSA-MachineKey" 已经被删除掉。如果还存在,就手动删除掉。

7.  建议运行一下 winmgmt /resetrepository 来修复WMI repository. WMI 出问题通常会影响到SCCM的正常运行。

8. 运行 C:\Temp\Client\Install.cmd

@rem Stop all SCCM Processes
net stop ccmexec
taskkill /F /FI "SERVICES eq ccmexec"
taskkill /F /IM ccmexec.exe
taskkill /F /IM ccmeval.exe
taskkill /F /IM ccmsetup.exe
taskkill /F /IM ccmrepair.exe
taskkill /F /IM CmRcService.exe
taskkill /F /IM SCNotification.exe
taskkill /F /IM msiexec.exe
taskkill /F /IM ccmrestart.exe
taskkill /F /IM Ccm32BitLauncher

@rem Set WMI to run in standalonehost
C:\Windows\System32\wbem\WinMgmt.exe /standalonehost

@rem Set the Windows Update service to run with shared memory
sc config wuauserv type= share

@rem Set the Windows Modules Installer service to manual start
sc config TrustedInstaller start= demand

@rem Set the Windows Firewall service to auto start
sc config MpsSvc start= auto
sc start MpsSvc

@rem Make sure C:\Windows\Installer exists
md C:\Windows\Installer

@rem Solution to "The system administrator has set policies to prevent this installation"
Reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer" /v DisableMSI /d 0 /t REG_DWORD /f

@rem Set DNS negative caching back to MS default
reg.exe delete HKLM\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters /v MaxNegativeCacheTtl /f

@rem Delete the contents of C:\Windows\SoftwareDistribution
Net stop wuauserv
powershell.exe -NoProfile -command "Get-ChildItem -Path 'C:\Windows\SoftwareDistribution\' -Recurse | Foreach-object {Remove-item -Recurse -path $_.FullName -Force }"
powershell.exe -NoProfile -command "Get-ChildItem -Path 'C:\Windows\System32\GroupPolicy\' -Recurse | Foreach-object {Remove-item -Recurse -path $_.FullName -Force }"
Net start wuauserv

@rem Uninstall the SCCM client if installed
%~dp0ccmsetup.exe /uninstall

@rem Delete .SDF and .SQLCE files
del /q C:\Windows\CCM\*.sdf
del /q C:\Windows\CCM\*.sqlce

@rem Uninstall Silverlight
@rem %SystemRoot%\System32\wbem\WMIC.exe product where caption='Microsoft Silverlight' call uninstall

@rem Kill any BITS transfers that might be in error.
%~dp0tools\PsExec.exe -s -accepteula bitsadmin.exe /reset /ALLUSERS

@rem delete certificate file
%~dp0tools\ccmdelcert.exe
PowerShell.exe -NoProfile -Command "Get-ChildItem Cert:\LocalMachine\SMS | Where-Object {$_.FriendlyName -like 'SMS*' } | Remove-Item"
%~dp0tools\setacl.exe -on "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys" -ot file -rec cont_obj -actn ace -ace "n:system;m:grant;p:full"
%~dp0tools\setacl.exe -on "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\19*" -ot file -rec cont_obj -actn ace -ace "n:administrators;m:grant;p:full"
PowerShell.exe -NoProfile -Command "Get-ChildItem -Path 'C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\' | Where-Object {$_.Name -like '19*' } | Remove-Item -Force"

If exist c:\Windows\SMSCFG.INI del /q c:\Windows\SMSCFG.INI

@rem Install Visual C++ 2013 Runtime
%~dp0x64\vcredist_x64.exe /install /quiet /norestart
%~dp0i386\vcredist_x86.exe /install /quiet /norestart

%~dp0ccmsetup.exe /source:%~dp0 /noservice /skipprereq:silverlight.exe SMSSITECODE=《站点代号》 FSP=《FSP地址》 DNSSUFFIX=《DNS后缀》 SMSMP=《MP的地址》 RESETKEYINFORMATION=TRUE

@Rem Set SCCM Client work hours
%SystemRoot%\system32\cscript.exe %~dp0Tools\Client_Work_Hours_Set_to_No_Days.vbs

8. 在控制面板里运行 “Configuration Manager” 

9. 运行 Actions 标签里的所以 Action:

猜你喜欢

转载自blog.csdn.net/aladinggao/article/details/120437056