Creating an SMS 2003 CCR within Excel
This post was previously released under a different blog and is being republished by me below. That site is no longer available. I am the original author.
I created the following function to create Microsoft SMS 2003 Client Configuration Requests from within Excel and dump them all out into a temporary directory for me to copy to the SMS inbox. For those that are unaware, you can “ask” SMS 2003 to remotely install the client by putting a CCR file into the INBOXES\CCR.BOX folder on the SMS Site server. Basically you just select your range of computer names, execute this sub, and it’ll let you know where the CCRs were generated (in a temporary folder). Just take a peek, copy them out to the CCR.BOX folder and (if SMS is setup correctly) you’re good to go!
1Public Sub CreateSMSCCR()
2
3 ' Version: 0.1 (First Release)
4 ' Excel Version: 2003
5 ' Language: English
6 ' Description: Function that creates a CCR for SMS 2003 from Excel
7
8 ' 30-Jun-2009: Created
9
10 Dim r As Range
11
12 Dim strComputer As String
13 Dim strError As String
14 Dim strMsg As String
15
16 Dim fn As Integer
17 Dim tmp As String
18
19 tmp = Date & " " & Time
20 tmp = Replace(tmp, ":", " ")
21 tmp = Replace(tmp, "/", "-")
22 tmp = Replace(tmp, "\\", "-")
23 tmp = Environ("TEMP") & "\\XLSCCR\_" & tmp
24 MkDir (tmp)
25
26 For Each r In Application.Selection
27
28 strComputer = r.Value
29
30 If strComputer = "" Then
31 strError = strError & " Skip " & r.Address & ": " & vbCrLf
32 ElseIf InStr(strComputer, Chr(32)) > 0 Then
33 strError = strError & " Skip " & r.Adderss & ": Has Space" & vbCrLf
34 ElseIf InStr(strComputer, ".") > 0 Then
35 strError = strError & " Skip " & r.Adderss & ": Has Period" & vbCrLf
36 Else
37 fn = FreeFile
38 Open tmp & "\\" & strComputer & ".ccr" For Output As #fn
39 Print #fn, "\[NT Client Configuration Request\]"
40 Print #fn, "Client Type=1"
41 Print #fn, "Forced CCR=TRUE"
42 Print #fn, "Machine Name=" & strComputer
43 Close #fn
44 End If
45
46 Next r
47
48 If strError <> "" Then
49 strMsg = "The following errors occured:" & vbCrLf & vbCrLf & strError & vbCrLf
50 End If
51
52 strMsg = strMsg & "Successful CCRs stored in " & tmp
53
54 MsgBox strMsg, vbOKOnly + vbInformation, "CCR Generator"
55
56End Sub
No comments