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:
- Connects to SMS.
- Finds the All Windows NT Systems collection.
- 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
-
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_
-
Change YOURSITECODE to the site code for your SMS site.
-
Save the file as C:\First.vbs.
-
In the SMS Administrator console, verify that you have a collection named All Windows NT Systems.
-
Click Start, point to Programs, point to Accessories, and then click Command Prompt.
-
At the command prompt, type the following:
Cscript C:\First.vbs
-
Press Enter.
-
In the SMS Administrator console, click Refresh.
-
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_ |