How to activate SMS agent via script

On our clients image the SMS 2003 agent are installed but not activated by default.
Above you find a script that I use for activate the agent as last step of client imaging deploy.
Remember to change the AssignedSite according to you SMS installation (for me is LTE).

Set smsclient = CreateObject("Microsoft.SMS.Client")

This last script are used by helpdesk for lunch remotely the first script.
Remember to change script according to your configuration; for me the script folder is C:\Deploy and the temp folder on remote client are C:\SYSTEM.SAV

Dim NomePC
NomePC = InputBox("Enter PC Name")

Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Deploy\SMSSiteAssign.vbs" , "\\"&strComputer&"\C$\SYSTEM.SAV\", OverwriteExisting

Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")

Error = objWMIService.Create("cscript.exe C:\SYSTEM.SAV\SMSSiteAssign.vbs", null, null, intProcessID)

If Error = 0 Then
    Wscript.Echo "Process was started with a process ID of " _
         & intProcessID & "."
    Wscript.Echo "Process could not be started due to error " & _
        Error & "."
End If

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s