The following procedure shows how to write and run a simple script that uses SMS. The script must be run on the SMS Site server and performs the following actions:

  1. Connects to SMS.

  2. Finds the All Windows NT Systems collection.

  3. Changes the collection name to All Windows NT Systems (any version, any type).

For additional information about writing and running simple scripts, see the following topics on TechNet:

Note   It is advised that you run the script examples in this documentation on a test SMS site before running them on your production SMS sites.

To write and run a simple script

  1. Open Notepad, and add the following sample script:

    Set SWbemLocator=CreateObject("WbemScripting.SWbemLocator")
    Set SWbemServices = SWbemLocator.ConnectServer( , "root\SMS\site_YOURSITECODE")
    Set SWbemObject = SWbemServices.Get("SMS_Collection.CollectionID='SMS000CS'")
    Wscript.Echo SWbemObject.CollectionID, SWbemObject.Name
    SWbemObject.Name="All Windows NT Systems (any version, any type)"
    SWbemObject.Put_
    
  2. Change YOURSITECODE to the site code for your SMS site.

  3. Save the file as C:\First.vbs.

  4. In the SMS Administrator console, verify that you have a collection named All Windows NT Systems.

  5. Click Start, point to Programs, point to Accessories, and then click Command Prompt.

  6. At the command prompt, type the following:

     Cscript C:\First.vbs
    
  7. Press Enter.

  8. In the SMS Administrator console, click Refresh.

  9. In the SMS Administrator console, the All Windows NT Systems collection name should now include (any version, any type).

Example

Set SWbemLocator=CreateObject("WbemScripting.SWbemLocator")
Set SWbemServices = SWbemLocator.ConnectServer( , "root\SMS\site_999")
Set SWbemObject = SWbemServices.Get("SMS_Collection.CollectionID='SMS000CS'")
Wscript.Echo SWbemObject.CollectionID, SWbemObject.Name
SWbemObject.Name="All Windows NT Systems (any version, any type)"
SWbemObject.Put_

See Also