Getting Started with GPMC Scripting

Before we dive in to the actual architecture of the GPMC scripting interface, let's briefly look at what you can and cannot do with scripting, as well as refer you to some additional scripting references and, give you some tips about what to do before writing your first line of code.

Tip 

You can download the full source code for the scripts in this chapter from the Sybex website at www.sybex.com .

GPMC Scripting Caveats

You can run GPMC scripts only on a machine that has GPMC installed, which, as I described in Chapter 1, means you must either run the scripts on a Windows Server 2003 member server or Domain Controller, Windows XP/SP1 (on which the GPMC will automatically load QFE326469), or Windows XP/SP2 or higher.

GPMC scripts, like the GPMC itself, can manage GPOs in Windows 2000 domains and Windows 2003 domains. You just need the GPMC loaded on the workstation on which you want to perform the scripting. Although you can use GPMC scripts to manage GPOs themselves , you cannot use scripts to manipulate the policy settings inside a GPO. In other words, you can use a script to create a GPO called "Desktop Lockdown" but you can't use a script to enable the policy setting that would Remove Run menu from Start menu. As you'll see a little later in the chapter, you can work around this limitation somewhat by importing the contents of an existing GPO into a new GPO.

Scripting References

If you're new to scripting, you may find that GPMC scripting is a tough place to start. The Microsoft documentation for GPMC scripts assumes a fairly detailed knowledge of Windows Script Host (WSH) operation and coding experience with one of the two WSH script engines: either VBScript or JavaScript. If words such as loops , variables , functions, and methods don't conjure fairly clear images in your head, work your way into scripting more gradually.

Tip 

Jerry Lee Ford's book Microsoft WSH and VBScript Programming for the Absolute Beginner (Premier Press, 2003) is a good place to start.

The foremost reference for Windows scripting comes from Microsoft Press, Microsoft Windows 2000 Scripting Guide (2002), written by "The Microsoft Scripting Guys." If you've never written a line of code in your life, you may find this book a little toward the deep end of the pool, but it's certainly a good investment that you'll use more and more as you get sophisticated with your scripts.

The best reference for writing and using GPMC scripts is the Platform Software Developer's Kit, or SDK. You can download the most current version from the MSDN website at www.microsoft.com/msdownload/platformsdk/sdkupdate . Don't be intimidated by the size of the download or the extent of the documentation in other areas. You only need the GPMC and VBScript documentation. The search and locator tools in the SDK make it simple to avoid the other reference material.

If downloading many megabytes of files just to get a bit of documentation doesn't appeal to you, the MSDN website has all the documentation online. The search engine in the Platform SDK is more flexible, but the Microsoft area of Google is almost as good. See www.google.com/microsoft.html.

Also, a version of the GPMC SDK documentation is included with the GPMC installation. See the file %programfi1es%\gpmc\scripts\gpmc.chm . You can also gain quite a bit of insight into GPMC scripting by studying the scripts in this folder. More on this topic at the end of this chapter.

References regarding Scripting Group Policy operations on the Internet are tough to come by, at least until the technology really starts to catch on. Check out the Win32Scripting site, http://cwashington.net.reach.net , and the MSDN scripting resources at http://msdn.microsoft.com/scripting. Microsoft hosts a series of scripting newsgroups under microsoft.public.scripting that get lots of traffic and is kind to beginners .

Scripting Tools

The simplest way to build a script is to open Notepad and start typing. But if you want the convenience of an integrated development environment (IDE) consider investing in an application intended primarily for developing scripts.

The best-of-breed application for building scripts, in my opinion, is PrimalScript from Sapien Technologies ( www.sapien.com ). PrimalScript simplifies writing scripts by coloring entries based on their use (variables, methods, functions, comments, and so forth), automatically displaying the properties and methods of registered classes, and allowing you to test your scripts without leaving the application. You'll also find a WMI (Windows Management Instrumentation) automation tool that lists all registered WMI classes and builds a script to enumerate all properties of a selected class.

Tip 

This functionality is also available in the free Scriptomatic utility from Microsoft. We'll explore Scriptomatic in Chapter 9.

Another excellent scripting application is VbsEdit from Adersoft ( www.adersoft.com ). Also, check out Web-Ed from Joe's Software ( www.jsware.com ), which costs less than the other two alternatives.



Group Policy, Profiles, and IntelliMirror for Windows 2003, Windows XP, and Windows 2000
Group Policy, Profiles, and IntelliMirror for Windows2003, WindowsXP, and Windows 2000 (Mark Minasi Windows Administrator Library)
ISBN: 0782144470
EAN: 2147483647
Year: 2005
Pages: 110

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net