BigFix OSD: Scripting Environment

Most of the documentation around Scripting Environments is focused on vendor-provided scripting toolkits, but there is a small reference “You can also build and import a customized Windows Preinstallation Environment (WinPE) without using a scripting toolkit of a specific vendor. For this purpose, you can specify the vendorName=Other option when you run the Scripting Environment Creator tool.” at http://www.ibm.com/support/knowledgecenter/en/SS63NW_9.5.0/com.ibm.bigfix.lifecycle.doc/Lifecycle/OSD_Users_Guide/t_create_scripting_env.html

I would like to do just that - have a customized WinPE that I can boot over the network from a Bare Metal server for troubleshooting, restoring system backups in WinPE, etc.

In the ScriptingEnvironmentCreator.zip, the command line appears to be

rbagent[64].exe -o rad-makescriptingenv scriptingEnvName=scripting_env_name exportdir=export_directory 
[osdtoolsdir=osdtools_dir] scriptingEnvPath=scripting_env_path vendorName=vendor_name [toolsPath=tools_path]

The Example is
For example: C:\ScriptingEnvironmentCreator> rbagent -o rad-makescriptingenv scriptingEnvName=IBM_Toolkit_env exportdir="C:\scripting_env_IBM" scriptingEnvPath="D:\IBM_Toolkit\ibm_utl_sgtkwin_9.63_windows_32-64\sgdeploy\WinPE_ScenarioOutput\Local_Asu_Config_Only_x64_BootOrder\ISO" vendorName="IBM"
The Examples imply using a folder containing files.
If I have an existing WIM file that I want to boot, how do I supply the path? Do I need to extract the files from the WIM image in order to create the scripting environment?
Do I need to use WAIK/ADK with the “oscdimg” command to generate an output? If so, what format of output (ISO / Joliet / UDF? Boot?)

I’ve made it past the initial point. I still have a problem though.

As the instructions are less-than-clear on this point, I did the following:

  • From the Windows Automated Deployment Kit (ADK), open an Elevated command prompt for “Deployment and Imaging Tools Environment”.
  • Create a Windows PE Enviornment (directory) using "copype.cmd"
    "c:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Windows Preinstallation Environment\copype.cmd" x86 c:\winpe_x86\WinPE
    This creates the following directory structure beneath c:\winpe_x86\WinPE:
  • fwfiles
  • media
  • mount
    The important part seems to be that the “media” directory contains a “sources\boot.WIM” file.

Create a RAD using ScriptingEvironmentCreator (must be in the rbagent working directory)
cd \ScriptingEnvironmentCreator\3.6 rbagent64.exe -o rad-makescriptingenv scriptingEnvName=Test_WinPE_x86 exportdir=c:\temp\ScriptingEnv scriptingEnvPath=c:\winpe_x86\WinPE\media vendorName=Other

This creates the RAD file at c:\temp\ScriptingEnv, along with a description file.
Import this RAD into the BigFix Console using the Scripting Environment dashboard.

The problem I still have though, is that rbagent64.exe destroys my startnet.cmd file, replacing it with the rbagent workflow.
Original startnet.cmd:
@REM Give me a nice command prompt and let me do what I need
wpeinit
start /wait cmd.exe /k

The startnet.cmd that rbagent64 so maliciously replaced:
@echo off
if exist c:\unattend.xml move c:\unattend.xml c:\unatend.xml.old
x:\Windows\system32\wpeinit.exe
echo Starting WMI Services
net start winmgmt
cd
reg add “HKLM\SYSTEM\CurrentControlSet\Control\Windows” /v ErrorMode /t REG_DWORD /d 2 /f
call x:\rbagent0.exe -o -d -v 4 -e AGENT_WPE startwinpe2
call x:\rbagent.bat
if exist c:\unattend.xml.old move c:\unattend.xml.old c:\unatend.xml.old
reg add “HKLM\SYSTEM\CurrentControlSet\Control\Windows” /v ErrorMode /t REG_DWORD /d 0 /f
exit

This is a basically a very expensive NO-OP function. I can push this scripting environment to a Bare Metal server, make a client boot it, and then … the client runs the startnet.cmd, which starts rbagent, rbagent finds it has nothing to do, the script exits, and the system reboots. Not what I wanted at all.

So, the next question is, how do I control the contents of startnet.cmd, and still package it into a RAD file that the Scripting Environment Dashboard can import?

Hello Jason,
you are right the original startnet.cmd is backed up into Windows\system32\startnet.rbobkp.cmd and the WinPE will contain our version of startnet.cmd. When the client boots and startnet.cmd starts rbagent than rbagent is in charge to execute the original version of startnet.cmd (that is startnet.rbobkp.cmd). But it seems that in your case something is not working properly.
First thing I would suggest to check if startnet.rbobkp.cmd has been created by rad-makescriptingenv rbagent command. Just stopping startnet.cmd execution (Ctrl-C) as soon as winpe starts.

Unfortunately the current implementation does not allow you to control the content of startnet.cmd once you have it imported. You need to update startnet.cmd in the WIM and then create a new scripting env and import it

regards Luca

Thanks much Luca, you’ve given me something to investigate at least. I’ll try booting into the scripting environment again and see if I can determine what is happening.

I do have a few follow-up questions -

Is there any way to extract the RAD file so that I can mount the WIM image embedded within? It might be easier to follow along and document the startup process if I don’t have to reboot repeatedly.

Is there any way to add the Scripting Environments to the Binding Menu so that I can choose it by PXE-booting the client? That would be preferable to having to create a new BigFix Action for each reboot.

If the Scripting Environment can be added to the Binding Menu, can I password-protect the Scripting Environment (as we can do for the OS Deployments) to prevent unauthorized users from launching the scripting environment?

I see several scenarios where these options would be helpful -

  • A Scripting Environment that supports disk wiping would be more convenient than booting from media when we decommission workstations.

  • A Scripting Environment hosting a copy of Tivoli Storage Manager WinPE (or Symantec Ghost, or Windows Server Backup) would be more convenient than booting from media when we need to perform system recoveries.

I must have grabbed the wrong WIM when I created the scripting environment. I rebuilt the scripting environment, and it’s working as you describe (the rbagent-generated startnet.cmd starts rbagent, then calls my original startnet.cmd).

Still looking for methods to launch the WinPE from the Binding Menu…

q: Is there any way to extract the RAD file so that I can mount the WIM image embedded within?
a: yes you can do that with the following rbagent command.
For instance:
rbagent64.exe -o radunpack e:\mydir\test.rad e:\myoutputdir
Generates a *.ramd file under e:\myoutputdir\engines that is the wim file you can analyze.

q: Is there any way to add the Scripting Environments to the Binding Menu so that I can choose it by PXE-booting the client?
a: The only way to deploy scripting environment is via the task 302. Currently Scripting env cannot be added to the binding menu.

Consider that disk wiping is provided out of the box. You do not need to have a scripting env to do that. Just use the task 300.

Agree with you that scripting env is useful for many scenarios and in some cases could be easier deploying password protected scripting env from binding menu than from BigFix Console

regards

Thanks, Luca, as always that’s very helpful. I’ll be submitting an RFE for adding Scripting Environments to the Binding Menu, and for Password-Protecting them.

Just an update on this: While I wasn’t looking, in arrives Task 302 “Deploy Scripting Environment on Bare Metal Targets”. Looking forward to trying this out.