Repair SCCM client remotely

Posted: October 2, 2014 in SCCM, Scripts

 

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

Comments are closed.