天天看點

【備忘】修複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開頭的檔案夾。

【備忘】修複SCCM用戶端

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

sc queryex winmgmt

taskkill /f /pid  <<上一個指令得到的 PID >>

【備忘】修複SCCM用戶端

6.  檢查确認 C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\ 目錄裡,開頭是19*的 "RSA-MachineKey" 已經被删除掉。如果還存在,就手動删除掉。

【備忘】修複SCCM用戶端

7. 運作 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” 

【備忘】修複SCCM用戶端

9. 運作 Actions 标簽裡的是以 Action:

【備忘】修複SCCM用戶端

繼續閱讀