Browse CLASSROOM TRAINING Find ONLINE TRAINING CONTACT us

SAPIEN Solutions

SAPIEN homepage
PrimalScript script editor+ide
PrimalScope script debugger
Free Tools script utilities
SAPIEN Press tech books
ScriptingAnswers.com learn+share
ScriptingOutpost.com online store
Blog.Sapien.com official blog
Contact Us

 

Welcome to the ScriptVault, where ScriptingAnswers.com users share their administrative scripts.

Have you written a script that accomplishes some administrative task? Please share it! Just navigate to the appropriate category and click the "Contribute to this category" link!

You are here: Top > Tutorials

Contribute to this category


Sub-Categories

(no categories are available)

 

Scripts

Remote Scripting Contributed by donj
Ever wish you could somehow "push" a script out to a remote computer and have it execute there? You can - with the WshController object built into the Windows Script Host (WSH). Here's a quick example: Dim oController, oRemoteScript Set oController = WScript.CreateObject("WSHController") Set oRemoteScript = oController.CreateScript("remote.vbs", "server1") oRemoteScript.Execute Do While oRemoteScript.Status <> 2 WScript.Sleep 10 Loop MsgBox "Remote Script finished." This will load up "remote.vbs" from your local machine, transfer it to Server1, execute it, and then display a messgae when the remote execution finishes. The real key is in the RemoteScript object, which you create by using the CreateScript method of the WSHController object. The Status property lets you know what's going on: 2 means finished, 1 means running, and 0 means the script hasn't yet executed. Cleverly handled, you could write a script that read through a list of computer names (or pulled them from AD), and executed a remote script on each. You could use the Status property to create a log file indicating which scripts successfully completed. The Error property (oRemoteScript.Error) can also be used to determine error information: Dim oError Set oError = oRemoteScript.Error WScript.Echo oError.Line 'line number of error WScript.Echo oError.Char 'column of error WScript.Echo oError.Description 'desc of error
XP SP2 Breaks Scripting Contributed by donj
With all the new security-fangled stuff in WinXP Service Pack 2 (SP2), you knew it would have some impact on administrative scripting. Here's what you've got to look forward to. Are you using scripting to connect to remote computers and perform WMI queries? Or using ADSI to manage local computer accounts? Well, brace yourself: Those technologies all connect via Remote Procedure Call (RPC), and the new Windows Firewall (included in SP2 and enabled by default) blocks those connections. Your scripts are done. The Microsoft Scripting Guys' blog lists a helpful script, which you can deploy as a login script, if you like, which helps address the problem. Here it is: Set objFirewall = CreateObject("HNetCfg.FwMgr") Set objPolicy = objFirewall.LocalPolicy.CurrentProfile Set objAdminSettings = objPolicy.RemoteAdminSettings objAdminSettings.Enabled = TRUE That'll open up the administrative ports so that RPC - and thus WMI and ADSI - work correctly for remote connections again. The blog entry also includes some useful tips on disabling the Windows Firewall completely (not recommended; that sucker is there for a reason, after all), and querying some of the properties from the Firewall.