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 


February 03, 2005

Automate Tasks with Scriptomatic


RSS
Subscribe to Windows IT Pro | See More Perl Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

When I was in college, I had the good fortune to take several computer science classes from one of Georgia Tech's legends, a man named gus Baird (his real name was Augustus, and he insisted that the g in gus be lower case). gus was a terrific instructor. Among the basic principles he taught was a simple one: Hard-working programmers solve problems, but good programmers solve their problems once by writing tools to automate repetitive tasks. The release of the new version of Scriptomatic from the Microsoft Scripting Guys (see http://www.microsoft.com/technet/scriptcenter ) reminded me of gus's maxim. Scriptomatic automates the process of writing several different kinds of WMI scripts, which has two benefits. For new scripters, it drastically lowers the difficulty of using WMI; for experienced scripters, it provides a simple way to crank out new scripts from a known set of basic scripts.
After you download the Scriptomatic 2.0 from http://www.microsoft.com/downloads/details.aspx?familyid=09dfc342-648b-4119-b7eb-783b0f7d1178&displaylang=en and install it, you'll find that you've suddenly gained the ability to create about multiple types of scripts. The original Scriptomatic could produce only VBScript code, but the new version can write scripts in the popular Perl and Python scripting languages, as well as in JavaScript. Better yet, you can easily target a single script at multiple computers, giving you an easy way to write one script that automatically gathers data from all your Exchange servers. Best of all, you can choose the output format for the script's data. The default dumps data on the command line, but you can also output plain text, HTML, Microsoft Office Excel, or XML format data to a file.
How easy is Scriptomatic to use? Check out the script I created (see below), which displays all the properties of the DSAccess objects exposed by Windows Management Instrumentation (WMI) on my two Exchange servers. Here's how I did it:
1. I launched Scriptomatic from BATMAN.
2. I clicked on the WMI Namespace pull-down menu and selected root\MicrosoftExchangeV2. (The list of namespaces and classes are dynamically generated according to the providers installed on the machine on which you're running Scriptomatic.)
3. From the WMI Class pull-down menu, I selected Exchange_DSAccessDC.
4. In the Target Computers field, I entered SUPERMAN as a computer name.
5. I clicked Update Script, then Run. Total: six clicks and eight keystrokes.
The script itself is easy to read. Admittedly, it doesn't do anything except echo the properties of the selected object, but if you don't already know the names and types of the properties in a particular class, using the script is an easy way to find out. With a little tweaking, you could easily turn this script into a tool that could report back on the current DSAccess configuration for all the servers in an domain, Exchange organization, or organizational unit (OU).
We won't see the scripting improvements promised for Exchange 12 for a while yet. In the meantime, you'll probably be surprised at how much data you can gather (and how many settings and behaviors you can change) using WMI. Scriptomatic and the related resources at the Scripting Center are a great way to get started with Exchange scripting.

On Error Resume Next
Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20
arrComputers = Array("BATMAN","superman") For Each strComputer In arrComputers
WScript.Echo WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer WScript.Echo "=========================================="
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftExchangeV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Exchange_DSAccessDC", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo "Caption: " & objItem.Caption
WScript.Echo "ConfigurationType: " & objItem.ConfigurationType
WScript.Echo "Description: " & objItem.Description
WScript.Echo "InstallDate: " & WMIDateStringToDate(objItem.InstallDate)
WScript.Echo "IsFast: " & objItem.IsFast
WScript.Echo "IsInSync: " & objItem.IsInSync WScript.Echo "IsUp: " & objItem.IsUp
WScript.Echo "LDAPPort: " & objItem.LDAPPort
WScript.Echo "Name: " & objItem.Name WScript.Echo "Status: " & objItem.Status
WScript.Echo "Type: " & objItem.Type
WScript.Echo
Next
Next

Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm: WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) __
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

End of Article



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
No Jobs, No Excitement at Apple's Last Macworld Keynote

Apple CEO Steve Jobs made the right move in skipping out on his company's last appearance at Macworld: In a Tuesday keynote address at the conference, Apple had no interesting new products to sell, opting instead to spend mind-numbing amounts of time on ...

Where is Microsoft NetMeeting in Windows XP?

...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...


Exchange Server and Outlook Whitepapers Protecting (You and) Your Data with Exchange Server 2007

StoreVault SnapManagers for Microsoft Exchange and SQL Server

Related Events Storage Consolidation for Your Microsoft Applications: Reducing Cost and Complexity

Top 10 Email Security Challenges and Solutions

Mastering Exchange 2007 Server Management – May 29, 2008 (11:00 AM EST)

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 © 2009 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing