Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


October 22, 2004

Scrutinizing Scriptomatic

Does it really write scripts for you?
RSS
Subscribe to Windows IT Pro | See More VBScript Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

The next step is to find out what the values for that property mean. Some property values are easy to figure out. For example, for the Win32_TerminalServiceSetting class's ActiveDesktop property, it makes sense that a value of 1 enables Active Desktop and a value of 0 disables it. (It's a good idea, however, to double-check that property values mean what you think they do.) But some values are less intuitive—what does a value of 0 mean for the class's UserPermission property? To decipher such values, you can poke around GUI-based tools and mentally map GUI settings to class properties. In this case, a quick look at the Terminal Services Configuration tool reveals a User Permission setting, which has two possible values: a value of 0, which enables Full Security, and a value of 1, which enables Relaxed Security. Other resources that can help you track down the meaning of property values include the Microsoft Developer Network (MSDN) WMI Reference (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_reference.asp) and Google (http://www.google.com).

Editing the Scriptomatic Script
After you run the Scriptomatic script to find the property information you need, you can save the script for editing. To do so, click the Save button to open a dialog box like the one that Figure 4 shows. Be sure to save the script as a .vbs file.

You can use Notepad or another text editor to edit the .vbs file. GetTSStatus.vbs, which Listing 1 shows, is an example of what the finished script might look like. This script retrieves and displays the Terminal Services settings for the local terminal server or for each specified terminal server. (The terminal servers must be running the WMI service.) To create GetTSStatus.vbs, I made two major modifications to the Scriptomatic script for the Win32_TerminalServiceSetting class:

Modification 1. I wanted to run my script on several servers, so I modified the Scriptomatic script so that it would run not only on the local terminal server but also on any specified remote terminal servers. I accomplished this capability with command-line arguments, an If...Then...Else statement, and a Select Case statement. I initially devised this system for a script that I discussed in "Check Service Status on Local or Remote Servers," March 2004, InstantDoc ID 41670.

To begin, I decided to use the following command to launch the script:

GetTSStatus.vbs [argument]

where argument can be one of the following:

  • One or more names of terminal servers, separated by a space
  • The word all (checks all the servers in Active Directory—AD)
  • The word file (an input file provides the terminal servers' names)
  • No argument is needed to run the script on the local terminal server.

    When no command-line argument is present, the If...Then...Else statement that callout A shows tells the script to connect to the local terminal server. When an argument is present, the Select Case statement that callout B shows evaluates the argument to determine on which terminal servers the script should run.

    If you plan to adapt GetTSStatus.vbs for use in your environment, you'll need to adapt the Select Case statement in two places. In the Case "file" code, you need to customize the INPUT_FILE_NAME constant. Replace C:\Scripts\Servers.txt with your input file's pathname. (In the input file, put each terminal server's name on a separate line.) In the Case "all" code, you need to customize the Set colComputers line. Replace LDAP://CN=Computers, DC=labyrinth, DC=com with the path to the servers on which you want to run the script.

    Modification 2. Because I knew that I wanted to run GetTSStatus.vbs on more than one terminal server, I adapted the Scriptomatic script so that it includes the name of the server when it displays the server's Terminal Services settings. As callout C in Listing 1 shows, I accomplished this by adding the sComputerName variable (which contains the terminal server's name) to each Echo statement in the TSServStat subroutine.

    What Scriptomatic Does Well
    It's overstating the case to say that Scriptomatic will write your scripts for you while you work on your golf game or Space Invaders scores. The tool has a number of limitations, with the biggest limitation being that it creates scripts that do one thing and one thing only: spit out a class's property values. However, what Scriptomatic does do (and does well) is help you obtain WMI class and property information. After you have that information, you can create robust scripts that perform a variety of tasks.

    End of Article

       Previous  1  [2]  Next  


    Reader Comments

    You must log on before posting a comment.

    If you don't have a username & password, please register now.




    Top Viewed ArticlesView all articles
    Microsoft Kills OneCare, Will Launch Free Security Solution

    Microsoft on Tuesday announced that it would retire its $50-a-year security subscription product, Windows Live OneCare, and replace it with a free solution codenamed "Morro." Unlike OneCare, however, Morro will focus only on core anti-malware features and ...

    The website is down because someone removed the X-Box

    What happens when a manager mistakes a server for a games console. ...

    Xbox 360 Overhaul Arrives with New UI, Avatars

    Xbox 360 owners who logon to the system's Xbox Live system this morning will receive the most significant functional change yet to the console's user interface, or dashboard. Dubbed the New Xbox Experience, this new front-end features a completely new ...


    Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

    Related Events Check out our list of Free Email Newsletters!

    Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

    Best Practices for Managing Linux and UNIX Servers

    Building an Effective Reporting System

    Related Scripting Resources Become a VIP member of the Windows IT Pro community!
    Get it all with the VIP CD and VIP access. A $500+ value for only $279!

    Subscribe to Windows IT Pro!
    Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

    Monthly Online Pass - Only $5.95!
    Get instant access to 10,000+ articles from Windows IT Pro Magazine!

    TechNet Virtual Labs
    Evaluate and test Microsoft's newest products.


    Windows IT Pro Home Register FAQ for Windows WinInfo News
    Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
    SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
    IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
     
     Windows IT Pro is a Division of Penton Media Inc.
     Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing