SYSTEMS MANAGEMENTthe script, save the listing into a file called disk.vbs and run thefollowing command:C:> cscript disk.vbsCscript.exe is a console-based scripting host that is packagedwith the Windows Script Host (WSH) and is used for running scripts.Note that the script in Figure 2 can be adapted to access avariety of information about managed resources. Information aboutmanaged resources can be viewed by downloading WMI administrativetools from http://www.microsoft.com/downloads/details.aspx?FamilyId=6430F853-1120-48DB-8CC5-F2ABDC3ED314&displaylang=en.CIM Studio, which is bundled in the WMI administrativetool set, lets administrators view class information in the CIM repository.For other sample scripts that perform a variety of useful systemadministration tasks, visit <strong>Dell</strong> <strong>Power</strong> <strong>Solutions</strong> online athttp://www.dell.com/magazines_extras.Figure 3 lists additional useful tasks that system administratorscan script.Scripting to execute processes on remote <strong>Dell</strong> systemsAdministrators can write scripts to execute processes on remotesystems, a technique that can be used in many ways to manage aWindows entity Description WMI-scriptable usage modelEvent logs Provide a repository of activities on Retrieve and query event logsa computerConfigure event log properties• Back up and clear event logsPrinters Manage printers in the enterprise • Monitor printers and print jobs• Manage printer connections onclient systemsRegistry Contains configuration settings for Create new registry entriesthe operating system, applications,Delete and update registry entriesand services under Windows • Back up the registryFiles/folders Contain valuable enterprise data • Manage files and folders (create, delete,and update)Enumerate filesManage shares• Monitor the file systemDisks and file Manage disks and file systems to Manage disk partitionssystem ensure continued access to data Manage logical disk drives• Manage disk spaceActive Directory Manage user account information in Create user accountsusers Active Directory Manage user accounts• Delete user accountsComputer asset Contains an inventory of hardware Install, upgrade, and remove softwareinformation information, including the operating • Retrieve system information, such assystem and other software installed operating system, memory, andon the remote computerdisk space• Manage computer startup andrecovery settingsComputer roles Manage computers and computer • Create, manage, and delete computerroles in Active Directoryaccounts in Active Directory• Manage the roles assigned to computersProcesses Manage running instances of an Monitor processesapplication or an executable fileCreate and terminate processes• Enumerate additional process propertiesFigure 3. Examples of scriptable administrative tasksBased on industrynetwork of <strong>Dell</strong> systems in theenterprise. Examples in this sectionillustrate the remote execu-standards, WMI helpstion of <strong>Dell</strong> OpenManage Serverenable consistent, uniform Administrator command-line interface(CLI) commands on a <strong>Dell</strong>management control and <strong>Power</strong>Edge server. To remotelyexecute other processes on targetmonitoring of systems nodes, administrators can customizethese examples. A completethroughout an enterprise. command reference can be foundin the <strong>Dell</strong> OpenManage ServerAdministrator Command-Line Interface User’s Guide, which is availableon the documentation CD that ships with every <strong>Power</strong>Edgeserver or online at http://docs.us.dell.com/docs/software/svradmin.Figure 4 shows an example script that executes a process on aremote system. To invoke the script on a remote server, calledMachineA in this example, save the preceding listing into a filecalled remote.vbs and run the following command:C:> cscript remote.vbs MachineA "omreport systemesmlog –outa c:\%COMPUTERNAME%_ESMLOG.TXT"The script in Figure 4 initiates the remote execution of theprocess and does not wait for the process to complete. Executingthe script exports the Embedded Server Management (ESM) loginto a text file on the remote target. This capability offers a rich setof possibilities for the remote scripting of <strong>Power</strong>Edge Servers usingServer Administrator CLI commands, including:• omconfig: Configures values using the CLI. Administratorscan use specific values for warning thresholds on componentsor prescribe what action a system should take when a certainwarning or failure event occurs. Administrators can also usethe omconfig command to assign specific values to a system’sasset information parameters, such as the purchase price ofthe system, the system’s asset tag, or the system’s location.• omdiag: Runs diagnostic tests against system hardware to isolateproblems.• omhelp: Displays short help text for CLI commands.• omreport: Produces reports of a system’s managementinformation.• omupdate: Installs the latest update packages for the system’sBIOS, firmware, and drivers.Administrators can run sequences of these commands using abatch file on a remote managed node. For a sample script that executesa batch file on a remote node, visit <strong>Dell</strong> <strong>Power</strong> <strong>Solutions</strong> onlineat http://www.dell.com/magazines_extras.68POWER SOLUTIONS June 2004
SYSTEMS MANAGEMENTstrComputer = WScript.Arguments.Item(0)strCommand = WScript.Arguments.Item(1)Wizard on the management station to performthe update during off-peak hours.Set objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" & strComputer & _"\root\cimv2:Win32_Process")errReturn = objWMIService.Create(strCommand,null,null,intProcessID)if errReturn = 0 ThenWscript.Echo strCommand & " was started with a process ID of " _& intProcessID & "."ElseWscript.Echo strCommand & " could not be started due to error " & _errReturn & "."End IfFigure 4. Sample WMI script for executing a remote processPerforming a remote software update under <strong>Dell</strong> OpenManageAdministrators can perform a remote software update for BIOS,firmware, and drivers by using the omupdate command or by usinga <strong>Dell</strong> Update Package.omupdate CLI command. To execute the omupdate command,an administrator would invoke the following:omupdate biosupdate path="\\network_share\file_name "This sample command refers to thenetwork share where the update file resides.In the absence of a network share, administratorscan copy the file to a temporarydirectory on the local system before performingthe update.<strong>Dell</strong> Update Package. Another optionis to copy the <strong>Dell</strong> Update Package, whichis a self-contained .exe file, onto theremote system. The .exe file can be directlyexecuted on the remote node by passingits command-line arguments for a silentinstallation of the package and rebootingthe system, if necessary. The WMI scriptlisted in Figure 5 illustrates a remote softwareupdate that passes in the computername and the name of the <strong>Dell</strong> UpdatePackage. In the script, note that the <strong>Dell</strong>Update Package is invoked with the /s /roption to perform a silent update andreboot of the system, if necessary.For a scheduled update, administratorscan use the Windows Scheduled TaskSecurity considerationsWMI scripts run in the security context ofthe administrator running the script. To runscripts on a remote computer, a user needsadministrative access on the remote system,thus helping to prevent malicious individualsfrom running destructive scripts on aremote server. Remote WMI scripting leveragesDistributed COM (DCOM) for interactingwith the WMI service running on theremote system.The scripts in this article set the impersonationlevel to “impersonate.” This settingimplies that the WMI service uses theadministrator’s security context to perform the requested operation.If the administrator’s security credentials are not adequate, errorssuch as “Access Denied” will occur when running the script.WMI provides a rich security infrastructure that can be configuredon a per-namespace basis. By default, the administrator’s grouphas full control of WMI on both local and remote computers, andusers in other groups do not have remote access to the computers.To view a computer’s security settings, invoke wmimgmt.msc fromthe command prompt, view the properties of the root node, and lookstrComputer = WScript.Arguments.Item(0)strDupFile = WScript.Arguments.Item(1)'* First copy the <strong>Dell</strong> Update Package to the remote systemSet objFSO=CreateObject("Scripting.FileSystemObject")ObjFSO.CopyFile strDupFile, "\\" & strComputer & "\C$\tmp\" & _strDupFile'* Launch the process on the remote systemSet objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" & strComputer & _"\root\cimv2:Win32_Process")strCommand = "C:\tmp\" & strDupFile & " /s /r"errReturn = objWMIService.Create(strCommand,null,null,intProcessID)if errReturn = 0 ThenWscript.Echo strCommand & " was started with a process ID of " _& intProcessID & "."ElseWscript.Echo strCommand & " could not be started due to error " & _errReturn & "."End IfFigure 5. Sample WMI script for a remote software updatewww.dell.com/powersolutions POWER SOLUTIONS 69