Creating DDRs for clients
Creating DDRs for clients allows you to discover clients from any source that you might have available. When the clients are discovered, their installation can be forced with Client Push Installation. To create DDRs from scripts, use the SMS Resource Generator Object, which is included with the Active Directory/SMS Synchronization Tools. This tool is available from the Microsoft Web site at https://www.microsoft.com/smserver.
Keep in mind the following points when using the SMS Resource Generator Object:
The SMS Resource Generator Object can be used on an SMS site server or SMS Legacy Clients.
The SMS Resource Generator Object files must be installed on any computer that runs SMS Resource Generator Object scripts. You can distribute these files with an SMS package that installs the Active Directory/SMS Synchronization Tools with a command line of
SMSAdsync.exe /s
To create the SMS Resource Generator Object Visual Basic programs, add a reference to "SMSRsGenCtl:SMS Resource Generator," and then DIM DDR as a new SMSResGen.
SMS Resource Generator Object does not have to be run on the clients that are to be discovered. The DDRs can be created on any SMS computer.
Sample C.33 shows creating a DDR. This sample can be extended to read in the required details from a spreadsheet, Active Directory, or any other source. To create a completely accurate DDR for the computer on which the script is run, additions would have to be made to collect TCP/IP addresses, subnets, and media access control (MAC) addresses.
Sample C.33 CreateDDR.vbs - creates a DDR
newresource=0 'set to 1 if you want to create a new computer DDR, rather than generate a DDR for the computer the script is run on Const ADDPPROP_NONE = &H0 Const ADDPROP_GUID = &H2 Const ADDPROP_KEY = &H8 Const ADDPROP_NAME = &H44 'get the current GUID, if available Set WshSHell=WScript.CreateObject("WScript.Shell") On Error Resume Next Version=WSHShell.RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\SMS\Client\Client Components\SMS Client Base Components\Installation Properties\Installed Version") if err=0 AND newresource<>1 then On Error Goto 0 if Version="99.9.9999.9999" Then 'it's a Advanced Client, so get the GUID from WMI GUID=GetObject("WinMgmts:root\CCM:CCM_Client=@").ClientID else 'it's a Legacy Client or 2.0 client GUID=WSHShell.RegRead( "HKEY_LOCAL_MACHINE\Software\Microsoft\SMS\Client\Configuration\Client Properties\SMS Unique Identifier") end if else 'it's not a client yet, so create a new GUID On Error Goto 0 GUID=CreateObject("Scriptlet.TypeLib").GUID end if On Error Goto 0 if newresource=1 then Randomize Computer="TestComputer" & Int(Rnd()*10000) else Set WshNetwork=WScript.CreateObject("WScript.Network") Computer=WShNetwork.ComputerName end if Set DDR=CreateObject("SMSResGen.SMSResGen.1") DDR.DDRNew "System", "CustomAgent", "NES" DDR.DDRAddString "SMS Unique Identifier", GUID, 64, ADDPROP_NAME DDR.DDRAddString "Name", Computer, 64, ADDPROP_NAME DDR.DDRAddString "Netbios Name", Computer, 64, ADDPROP_KEY Dim IPAddress(3), IPSubnet(3), MACAddress(3) IPAddress(0)="123.234.12.23" IPAddress(1)="123.234.12.32" IPSubnet(0)="123.234.12.0" IPSubnet(1)="123.234.12.0" MACAddress(0)="00:02:A5:B1:11:68" MACAddress(1)="00:02:A5:B1:11:69" DDR.DDRAddStringArray "IP Addresses", Array(IPAddress(0),IPAddress(1)), 64, ADDPROP_ARRAY DDR.DDRAddStringArray "MAC Addresses", Array(MACAddress(0),MACAddress(1)), 64, ADDPROP_ARRAY DDR.DDRAddStringArray "IP Subnets", Array(IPSubnet(0),IPSubnet(1)), 64, ADDPROP_ARRAY DDR.DDRWrite "MyDDR.DDR" DDR.DDRSendtoSMS Set FSO=CreateObject("Scripting.FileSystemObject") FSO.GetFile("MyDDR.DDR").Delete
For More Information
Did you find this information useful? Please send your suggestions and comments about the documentation to smsdocs@microsoft.com.