Export & share MDT Applications (New Tool) November 6, 2009
Posted by keithga in Uncategorized.comments closed
New for MDT 2010
Presented here is the MDT Application Export Tool (MDTAppExport.exe). This tool will export the settings for a selected Application in MDT 2010 into a Powershell *.ps1 script file. This portable powershell script file can be used to import the Application settings into another instance of MDT 2010.
One of the coolest new features of MDT 2010 is the new Powershell Programming interface. This interface makes it possible for 3rd party programs to Read, Manipulate, and Create settings in your MDT 2010 environment.
Still, Powershell is a relatively new programming language. And many IT Pros may still be unfamiliar with it. Which makes this tool so cool, you can create powershell scripts without knowing powershell.
Advantages
Exporting to Powershell provides a good way to share Application metadata between MDT 2010 Shares:
- Upgrade your existing MDT 2008 Deployment Share to MDT 2010, and extract out all of your applications for archival.
- Move individual applications between test and production environments without copying other items still in test.
- Use Powershell scripts as a way to document/store the settings for each application in your environment.
- Share your solutions to difficult/complex application installations to IT Community Forums (please don’t share software files you don’t have the rights to redistribute :^) ).
Notes
While running the Application Script Export Tool Wizard, Simply select one of the Deployment Shares already present in the Microsoft Deployment Toolkit 2010 Workbench. Then Select the Applications you wish to export, and the Target location they should be exported to.
Most applications should export without trouble 97-98% of the time. However it is generally a good idea to review the settings created by the tool to ensure that everything is correct.
This script will create one Powershell *.ps1 script file for each item selected in the wizard. If an Application has dependencies defined in the MDT 2010 Workbench, then the dependencies will also be included in the same *.ps1 file.
All Source Files imported into the Deployment Workbench when the Application was created will be copied to the Target Location.
Limitations
- You must have MDT 2010 installed on the same machine this tool is running on.
- You must have your Deployment Share visible in the MDT 2010 Deployment workbench.
- This tool will create one *.ps1 for each application Selected, and all dependent applications will be imported to the same *.ps1 file.
- If you have hidden and or non-enabled applications defined, they will also be Displayed in the Application Script Export Tool Wizard.
- This tool will create scripts with the –hidden and –enabled settings as defined in the workbench.
- This tool will *not* export the Language Field. Language Field is not used in ZTIApplications.wsf
- If you are exporting Sources, the files must be located in the Deployment Share, meaning that you can’t have a %ResourceRoot% at a different location from the %DeployRoot%.
- If there were any errors in copying the Sources to the Target, there should be an
“# ERROR – <something>”
line present in the source. - Please ensure that all application items imported into MDT are placed in their own directory. Installing more than one Application Item from the same directory may result in duplicate files in the MDT system.
Links
http://cid-5407b03614346a99.office.live.com/self.aspx/Blog/MDTApplicationExport.zip
Further
This tool has tremendous potential. Beyond just coping application settings between MDT 2010 Servers.
We are already using this tool here at Xtreme Consulting Services to create “repositories” of applications that can be used to quickly build out MDT 2010 deployments for our customers. A fullly functional MDT 2010 Litetouch Deployment System setup on site in Hours, not Days, or Weeks.
It could also be the start of a public repository of Applications for MDT Administrators. Although I have not yet figured out a great hosting site for this kind of community/forum. Have some ideas, drop me a line.
Update: 11/13/09 – I updated the tool to generate scripts that support Powershell v1.0 better, and to fix a problem with applications with spaces in the shortname.
Keith
Keith Garner is a Deployment Specialist with Xtreme Consulting GroupCapturing Debug Information from Client Scripts (New tool) November 5, 2009
Posted by keithga in Uncategorized.comments closed
(New for MDT 2010)
From my previous post, I wrote that for MDT 2010, there is a new common command line parameter called “/debugcapture”. This command line parameter will disable the common MDT error handling functions and let any errors echo out to the console.
This is great when calling MDT Client scripts directly from cscript.exe, however it is not helpful when calling from within a MDT Litetouch Task Sequence. Since the MDT 2010 Litetouch Stand Alone Task Sequencer does not capture the output from the client scripts for logging.
Introducing ZTICscript
To solve this problem, I developed a wrapper script called ZTICScript. It will call a client script with the new /debugcapture flag, capture any error output, and copy the error lines to the standard bdd.log system.
It’s been really great when developing new client scripts that may have errors, and speeds up the identification of bad code. As I mentioned in my earlier post, using the information captured with the /debugcapture flag, I can identify the line number and sometimes the variable name of of any errors.
Another cool thing about getting the output from /debugcapture rather than from the default error handler, is that it can also capture compile time errors. For example, if you have written a script with an unterminated string:
wscript.echo "Unterminated string
These errors are nasty, since the bdd.log will not display any errors from the script. Sometimes you may need to go into the smsts.log file to find out which script it was executing when it failed.
Step 1 – Modify your TS.xml file.
Open up your Ts.xml file ( %deployroot%\control\<dir>\ts.xml ), or ( %programfiles%\microsoft deployment toolkit\templates\client.xml ), and replace every instance of
cscript.exe
with
cmd.exe /c %scriptroot%\zticscript.cmd
For example, if you are trying to capture debugging information from the ZTINextPhase.wsf script, the command line should look like (single line):
cmd.exe /c %scriptroot%\zticscript.cmd "%SCRIPTROOT%\ZTINextPhase.wsf"
Step 2 – Create ZTICScript.cmd and ZTICScript_log.wsf.
Get the script files from here, and copy them to your %DeployRoot%\script directory.
That’s it!
Now, if there are any errors in your script that would normally be caught by the standard MDT Exception Handler, they will instead be output to the console and piped to the bdd.log file. Very helpful in scenarios where normal bdd.log files are not returning the correct information.
Please note, that for some reason, I have been unable to get this script to wrap around LTISysprep.wsf 100% of the time. I just haven’t had the time to debug what’s happening. I think it may have to do with the heavy resource requirements of sysprep.exe.
Attachments:
http://cid-5407b03614346a99.office.live.com/self.aspx/Blog/ZTICScript.zip
Keith
Keith Garner is a Deployment Specialist with Xtreme Consulting GroupTroubleshooting Database Issues with MDT 2010 November 4, 2009
Posted by tmintner in MDT 2010, Troubleshooting, Uncategorized, VBscript.Tags: Database, MDT, Troubleshooting, ztigather
add a comment
There have been a few really great posts on how to troubleshoot database connection issues with BDD and MDT over the past couple of years. Ben Hunter wrote a great post on this here: http://blogs.technet.com/benhunter/archive/2007/07/10/bdd-2007-troubleshooting-database-issues.aspx. However, if you try to do this with MDT 2010 you will get a few errors in the output. In MDT 2010 the structure of the scripts have changed somewhat and the functionality of ztigather has been extended to also gather additional information that now requires some compiled code. So with MDT 2010, you can perform the same steps with the following modifications:
1. Create a folder on the client device and copy the following files from the deployment point to this folder:
- ZTIGather.wsf
- ZTIGather.xml
- ZTIUtility.vbs
- CustomSettings.ini
- ZTIDataAccess.vbs (new script file in MDT 2010 for accessing data sources)
- Create a Tools folder and create an X86 and X64 folders underneath the Tools folder. Copy the Microsoft.BDD.Utility.dll file from the Tools\X64 and Tools\X86 folders in your deployment share to your newly created Tools\X86 and Tools\X64 folder
2. Delete C:\MININT directory if it already exists. This folder can also be located at X:\MININT if the C drive is not available.
NOTE: MDT stores configuration and progress information in the MININT folder, if this folder is not removed between tests then the results will be invalid.
3. From the command prompt navigate to the newly created folder and execute the rule processing script using the following command:
“cscript.exe ZTIGather.wsf /debug:true”
The script will then be processed and the results outputted to the command prompt and a log file ( .\MININT\SMSOSD\OSDLOGS\ZTIGather.log)
NOTE: The script can be run within Windows PE or the host operating system.
4. Review the results of the script.
Enjoy!
Tim Mintner is a Principal Consultant with Xtreme Consulting Group
Prevent machine from falling asleep. November 4, 2009
Posted by keithga in Uncategorized.comments closed
Erik, asked about a post from last week regarding “Falling asleep on the job (task)”:
Would you mind sharing that tool you wrote
?
Also, is ES_CONTINUOUS and ES_SYSTEM_REQUIRED flags cleared when the system is rebooted?
What I am thinking of is if you run a util that set the above at the beginning of the Lite Touch process. Would you need to run another util that that clears the EXECUTION_STATE flag at the end of the Lite Touch sequence? Or will it be cleared automatically when you reboot the computer using a Restart Computer entry in the Task Sequence?
More background
When you set the Execution state, although you are setting the state of the entire system, the Operating System will only keep track of the requested state during the lifespan of the Thread that made the call. Once the thread (or process) exits, the request is no longer valid, and the system goes back to whatever the last state was.
In MDT 2010, this was easily solved by making the call to SetThreadExecutionState() from within the litetouch.wsf script. Since the Litetouch.wsf script thread stayed alive during the Task Execution phase (in the background), that worked out fine.
Also, the Thread Execution State does not persist across reboots, so cleanup was not necessary, just exit out of litetouch.wsf, and the machine can go into hibernation.
Side Effects
This *may* have a side effect. If you choose to display the final Summary Dialog Box at the end of the Litetouch process, the machine will stay alive during that time, until the user comes back to the machine.
New Tool
Just in case you have “Other” tasks that require you to keep a machine alive, here is a tool I wrote back in 2005 (cleaned up here). This *.exe tool will keep a Windows Machine alive while it is running. Meaning the machine won’t be able to fall asleep either by hibernate or by suspend.
The tool has to remain running while you want the machine to stay awake. So you can run it with the command line:
start KeepAlive.exe
This program is a Windows Program and will run with no user interface. You can see if it’s running by checking the task manager.
When you are done, just run the command again (Either with or without the –close flag:
KeepAlive.exe
If KeepAlive.exe detects that another instance of itself is running in the background holding up Thread Execution State, the new instance of KeepAlive.exe will signal to the previous instance to stop and release the Execution State.
The source code is included
Link
http://cid-5407b03614346a99.office.live.com/self.aspx/Blog/KeepAlive.zip
Keith
Keith Garner is a Deployment Specialist with Xtreme Consulting GroupWriting custom scripts with MDT 2010 November 3, 2009
Posted by tmintner in MDT 2010, Uncategorized, VBscript.Tags: custom script, MDT 2010, VBscript
6 comments
Ben Hunter wrote a great blog post a few years ago on how to create a custom VBscript to use with BDD 2007 (http://blogs.technet.com/benhunter/archive/2007/04/15/bdd-2007-ndash-tips-and-tricks-ndash-how-to-write-a-custom-script.aspx). Ben’s script template will still work with MDT 2010 however If you have spent any time looking at the scripts in MDT 2010 you will notice that the format of the built in scripts have changed. So you might be wondering how to create a custom script with MDT 2010. MDT 2010 introduced some script structure changes to better handle error reporting and to make the scripts a bit easier to read and test. The new template is listed below. So how do you use the template? Start by pasting the following code into a script file with a WSF extension (somefile.wsf). After creating the file edit the Class ScriptName with the name of your script. As an example if you named your custom script somescript.wsf then the Class would be Class SomeScript.
Now that you have your script and your class named correctly you can add your code under the Function Main. Once you are finished you just need to save the file and put it into the scripts folder in your deployment share.
So what does the new structure give you beyond what Ben’s post originally pointed out? First it gives you some nice debugging capabilities. Normally you would run your script by calling cscript.exe “%scriptroot%\somescript.wsf” in the task sequence. If you want to use the advanced debugging you can add /debugcapture. Adding the /debugcapture will turn on advanced debugging features by disabling the standard On Error Resume Next in the scripts and capturing any errors in the script that might occur and displaying them to the screen. For example if you forgot to declare a variable the /debugcapture will display the variable that could not be found and the line number that the error occurred on. You can also use your own test hook scripts to unit test the different functions in the script (more on that later). For right now, enjoy the template and we will definitely be posting more custom script samples over the next few months!
<job id=”ZTIConnect”>
<script language=”VBScript” src=”ZTIUtility.vbs”/>
<script language=”VBScript”>
Option Explicit
RunNewInstance
‘//—————————————————————————-
‘// Global Constants
‘//—————————————————————————-
Const ANSWER_TO_LIFE_THE_UNIVERSE_AND_EVERYTHING = 42
‘//—————————————————————————-
‘// Main Class
‘//—————————————————————————-
Class ScriptName
‘//—————————————————————————-
‘// Global constant and variable declarations
‘//—————————————————————————-
Dim iRetVal
‘//—————————————————————————-
‘// Constructor to initialize needed global objects
‘//—————————————————————————-
Private Sub Class_Initialize
End Sub
‘//—————————————————————————-
‘// Main routine
‘//—————————————————————————-
Function Main
‘Insert your code here
End Function
End Class
</script>
</job>
Tim Mintner is a Principal Consultant with Xtreme Consulting Group
Install Driver EXE Package (New Tool) November 2, 2009
Posted by keithga in MDT 2010, Uncategorized, VBscript.comments closed
New Tool! ZTIInstallDriverExePackage.wsf
As I described in my earlier post. MDT has a great system for Driver Management. You import a driver via it’s *.INF file, and that driver will be installed on every machine where that PnP ID is found. No need to associate a driver via a Make/Model.
However, there are some cases (very rare), when a driver package can’t be installed by *.inf file alone, or a *.exe installation package may need to be installed along side a specific piece of hardware.
The ZTIInstallDriverExePackage.wsf tool was designed to allow an Driver *.exe installation package to associate with a set of PnPID’s defined in the Workbench.
Steps
- Download the Driver Installation *.exe Package to your MDT Workbench machine. Ensure that you copy the package to its own directory.
- Add the Application to the MDT workbench as you would any other Application Installation Package.
- You will need to extract out the GUID for the Application added. It may be in the depoyment share under \Control\applications.xml
- Extract out as much of the driver *.inf component as you can to a separate directory (not a sub-directory). There are several tools available on the internet for extracting out compressed files from Self extracting Executables. My personal favorite is 7-Zip (see 7-zip.org)
- Add the Driver Package to the MDT workbench as you would any other Driver Package.
It is not necessary that it be fully functional. However the PnPID’s should be properly added. - Once the driver has been imported successfully. Open the Properties for the new device
- You may disable the driver. Uncheck “Enabled”. Disable only if you want the Exe Package to be the only way for the driver to be installed.
- Add the following string to the comments section:
“DriverExePackage {GUID}”
Where {GUID} is the Application GUID extracted from the 3rd step above.
- Copy the ZTIInstallDriverExePackage.wsf file to the Deployment Share under …\Scripts\
- Add a new Step in your Task Sequence calling ZTIInstallDriverExePackage.wsf
cscript.exe “%ScriptRoot%\ZTIInstallDriverExePackage.wsf”
Script Flow
ZTIInstallDriverExePackage.wsf will operate in a manner similar to ZTIDrivers.wsf.
- It will enumerate though all hardware devices on the machine, and extract out their PnPID’s.
- For each Hardware PnPID found, it will try to match that ID with any driver found in the Deployment Share.
- For each Driver package found it will search the comments field, searching for the “DriverExePackage” string followed by the Application GUID.
- The script will then call ZTIApplications.wsf with the GUID from the Comments section.
ZTIApplications.wsf will do a good job of ensuring that the corresponding application is installed only once.
Assumptions
- In most cases, I personally recommend sticking with the *.inf only method of driver installation. The Exe only method should only be used in rare cases.
- This script uses the drivers.xml file from the distribution share to associate the PnPID’s with the Application GUID. It is important that the MDT Workbench Add the driver package to the system. IT is not necessary for the driver package to actually work. The Driver Package can be disabled if it is failing to work, it should not be removed.
- To associate a Device with an Application Item, you also need to add the Application GUID of the device prefixed with the string “DriverExePackage” into the comments of the driver in the MDT Workbench.
Links
http://cid-5407b03614346a99.office.live.com/self.aspx/Blog/ZTIInstallDriverExePackage.zip
Keith
Keith Garner is a Deployment Specialist with Xtreme Consulting Group