The following script is usefull toinstall SCCM 2012 client. You can also include it in a standard GPO: it checks first if the client is already installed in the machine:
Option Explicit
On Error Resume Next
Dim FICHERO, MAQUINA
Dim strServiceSCCM,strServiceFramework
Dim objNETWORK, objFSO, objShell,objSysEnv
Dim strSMS_InstallPath, strSMS_Parameters
Dim strReinstallService
Set objNETWORK = WScript.CreateObject("WScript.NETWORK" )
Set objFSO = CreateObject("Scripting.FileSystemObject" )
Set objShell = WScript.CreateObject("WScript.Shell" )
Set objSysEnv = objShell.Environment("Process" )
strServiceSCCM = "CcmExec"
strSMS_InstallPath = "\\@Servername@\client$\ccmsetup.exe"
strSMS_Parameters = "SMSSITECODE=PLM"
MAQUINA = objNETWORK.COMPUTERNAME
' If isServiceRunning(strServiceSCCM) = False Then
' objShell.Run strSMS_InstallPath & " " & strSMS_Parameters, 1, True
' strReinstallService = strReinstallService & " | " & strServiceSCCM
' End If
If objFSO.FolderExists(objSysEnv("SYSTEMROOT" )&"\CCM" ) Then
' Check for an SMS executable
If ObjFSO.FileExists(objSysEnv("SYSTEMROOT" )&"\CCM\CcmExec.exe" ) Then
Wscript.quit
End If
End If
objShell.Run strSMS_InstallPath & " " & strSMS_Parameters, 1, True
SET FICHERO = objFSO.opentextfile ("\\@Servername@\client$\ccmsetup\client$\result.txt",8, TRUE)
FICHERO.WRITELINE MAQUINA & " -- " & Now & strReinstallService
FICHERO.CLOSE
' Function to check if a service SCCM is running
Function isServiceRunning(strService)
Dim objWMIService, strWMIQuery
strWMIQuery = "Select * from Win32_Service Where Name = '" & strService & "' and state='Running'"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
If objWMIService.ExecQuery(strWMIQuery).Count > 0 Then
isServiceRunning = True
Else
isServiceRunning = False
End If
End Function
0 commenti:
Post a Comment
Give me you feedback!