Microsoft Identity Integration Server 2003 Developer Reference |
The Identity Manager can create a Visual Basic Scripting Edition (VBScript) script that you can use to run a management agent from a command line or at a scheduled time. The generated script has all the commands needed to connect to the WMI Service of a local or remote server and run a specified management agent.
This topic describes the following procedures:
Caution Do not run a management agent through a script when deleting any management agent as you can cause a failed run and/or corrupt a management agent configuration.
To create a script to connect to a local server
The following example shows a script that was created using the previous procedure to connect to the WMI Service on a local server and then run the full import run profile of the Fabrikam HR MA management agent.
Set Locator = CreateObject("WbemScripting.SWbemLocator") rem rem Credentials must only be specified when Microsoft Identity Integration Server is on remote system. rem rem Set Service = Locator.ConnectServer("MyServer", "root\MicrosoftIdentityIntegrationServer") rem Set Service = Locator.ConnectServer("MyServer", "root\MicrosoftIdentityIntegrationServer", "Domain\Me", "MyPassword") rem Set Service = GetObject("winmgmts:root\MicrosoftIdentityIntegrationServer") Set MASet = Service.ExecQuery("select * from MIIS_ManagementAgent where Guid = '{1D99EC00-87BC-41BF-A65D-AF46217AC686}'") for each MA in MASet WScript.Echo "Running " + MA.name + ".Execute(""Full Import"")..." WScript.Echo "Run completed with result: " + MA.Execute("Full Import") next
The script uses the credentials of the current user to run the script. If the current user is not a member of a group that has permissions to run the scripts, you can use the Run As command to specify alternative credentials to run the script.
To specify alternative credentials
runas
/user:<domain>\<username> <script
name>
runas
/user:Fabrikam\Jeff fullimport.vbs
You can modify the script to connect to a remote server by taking the following steps:
To modify the script to connect to a remote server
rem Set Service = GetObject("MyServer", "root\MicrosoftIdentityIntegrationServer")
Set Service = GetObject("winmgmts:root\MicrosoftIdentityIntegrationServer")
The following example shows a script that was modified to connect to a remote server using the current user credentials to run a management agent. The name of the server is FabrikamDomainSvr:
Set Locator = CreateObject("WbemScripting.SWbemLocator") rem rem Credentials must only be specified when Microsoft Identity Integration Server is on remote system. rem Set Service = Locator.ConnectServer("FabrikamDomainSvr", "root\MicrosoftIdentityIntegrationServer") rem Set Service = Locator.ConnectServer("MyServer", "root\MicrosoftIdentityIntegrationServer", "Domain\Me", "MyPassword") rem rem Set Service = GetObject("winmgmts:root\MicrosoftIdentityIntegrationServer") Set MASet = Service.ExecQuery("select * from MIIS_ManagementAgent where Guid = '{1D99EC00-87BC-41BF-A65D-AF46217AC686}'") for each MA in MASet WScript.Echo "Running " + MA.name + ".Execute(""Full Import"")..." WScript.Echo "Run completed with result: " + MA.Execute("Full Import") next
If you want to use alternative credentials to run the script remotely, use the runas command, as shown in the previous procedure.
Caution We do not recommend storing user credentials in a script. If you need to run a script under a different user context, in most cases you should use the runas command to run the script. If you must include the username and password in the script, store the script in a secure folder that has the same security level as the Microsoft Identity Integration Server 2003 folder. Limit access to that folder.
Caution Do not use a script that connects to a remote server to connect to a local server. Specifying the user name and password in a script intended to connect to a remote server causes the connection to fail. For more information, see the strUser parameter in the topic SWbemLocator.ConnectServer in the Platform SDK.
You can use the Task Scheduler in Windows Server 2003 to run your scripts automatically. For more information about the Task Scheduler, see the Windows Server 2003 Help.