October, 2014

Versioning and naming your base SOE .wim during OSD

If you replace the base wim (via build and capture) frequently it can be good to set versions and date the wim file that you import. It makes it easy to revert back if a change didn't go so well. Below are the steps in my build and capture to do versioning and work around a bug with naming your captured image.

1. At the top of my task sequence I set a task sequence variable SOEBaseVersion, each time I do a build and capture this is incremented.

Set SOEBaseVersion

2. After 'Setup Windows and Configuration Manager'  I have a 'Run Command Line' step with the following command so that we can utilize that value on deployed machines if ever needed:

cmd.exe /c reg add HKLMSoftwareSOE /v SOEBaseVersion /d "%SOEBaseVersion%"

Set SOE Reg

 

3. Next I run a vbscript to set the task sequence variable TSDate to the date in the format YYYYMMDD

Set env = CreateObject("Microsoft.SMS.TSEnvironment")
env("TSDate") = DatePart("yyyy",Date) & Right("0" & DatePart("m",Date), 2) & Right("0" & DatePart("d",Date), 2)

Screenshot 2014-10-22 16.21.49

 

4. In the 'Capture the Reference Machine' step I can then use the TSDate Variable to create a unique file name for the capture and also use the version field. There is a bug with the SCCM console as it doesn't use the Description field when importing, the next 2 steps resolve that.

Capture

 

5. Connect to OS Capture share.

Connect to share

6. Copy imagex to a package, then use it to run the following command line

imagex.exe /info R:\WIN81_x64_Base-%TSDate%.wim 1 "Windows 8.1 Enterprise" "WIN81 x64 - %TSDate%"

Set Image Description

 

7.  You can now import into SCCM with all the fields filled in correctly

Add Operating System Wizard

 

 

 

MDT UDI Pre-flight checks

UDIPreflight

One of the best things to come out of MDT is the User Driven Interface (UDI) and the preflight page which allows custom checks. You can control whether a check passes or not with the exit code of the script. The locations to put preflight scripts is MDT Toolkit files packagetoolsArchPreflight

 

Check Hardware Model

This is a VBscript that goes through from Win32_ComputerSystem Model and exits with 0 if it finds a match.

CheckHWModel

Preflight Name and Type

Display Name: Check Hardware Model
Type: Shell Execute Task

Preflight Parameter Settings

File Name: %windir%system32cscript.exe
Parameters: PreflightOSDCheckHWModel.vbs $OSDComputerName
Status Bitmap: imagesram.bmp

Exit Code Values

Type Status Matches Value Displayed Message
Success Success 0 Hardware Model Supported
Error Error 1 This Model is not currently supported to run the Windows 7 SOE.

 

 

Check TPM Chip

This is a powershell script that exits 0 if it is a VM or a MAC (machines allowed to not have TPM) then checks for the existence of a TPM chip. It then checks to see if it has been activated in the BIOS.
Takes a few seconds to run, hopefully I can optimise it in the future.

CheckTPM

Preflight Name and Type

Display Name: Check TPM Chip
Type: Shell Execute Task

Preflight Parameter Settings

File Name: %windir%System32WindowsPowerShellv1.0powershell.exe
Parameters: -executionpolicy bypass -file %deployroot%toolsx64PreflightOSDCheckTPMChipV2.ps1
Status Bitmap: imagesram.bmp

Exit Code Values

Type Status Matches Value Displayed Message
Success Success 0 TPM chip is enabled
Error Error * No TPM Chip found. Please enable in the BIOS before continuing
 Error  Error  20  Please activate the TPM chip in the BIOS

Check AD Name

I have a script that looks to the AD to warn if the computer name exists. There's quite a bit of work involved to get it working, will share if anyone is interested.

 

 

Download scripts

 

Setting lockscreen and wallpaper based on resolution for Windows 8.1 during OSD

lockwall

Lockscreen

First you need to create and name files in this convention (we used png files and renamed them to jpg - this somehow works)
LockScreen___2160_1440.jpg
LockScreen___1024_0768.jpg

We used the top 10 resolutions on client machines and  also the Surface Pro 3 resolution
1680 x 1050
1920 x 1080
1280 x 1024
1366 x 768
1024 x 768
1600 x 900
1920 x 1200
1280 x 800
2560 x 1440
1600 x 1200
2160 x 1440

Notice each number is 4 characters.

During OSD run the following commands using a package with the images in it

xcopy /s LockScreen*.* C:ProgramDataMicrosoftWindowsSystemDataS-1-5-18ReadOnlyLockScreen_Z /y
xcopy /s LockScreen*.* C:ProgramDataMicrosoftWindowsSystemDataS-1-5-18ReadOnlyLockScreen_Y /y
xcopy /s LockScreen*.* C:ProgramDataMicrosoftWindowsSystemDataS-1-5-18ReadOnlyLockScreen_X /y

The reason for copying to 3 folders is that if the resolution changes it uses the next letter (Internet told me, haven't confirmed)

 

Wallpaper

Create a new package separate from the lockscreen package with the files above however with a new naming convention so the script below is happy
BackgroundDefault2160x1440.jpg
BackgroundDefault1024x768.jpg
and so on.

In your unattend.xml file Under Specializeamd64_Microsoft-Windows-Shell-Setup_neutralThemes
set DesktopBackground to "C:windowsWebWallpaperHappySCCMBackgroundDefault.jpg"
changing HappySCCM to your org/theme name.

Settings for theme

Settings for theme

In your package add the script https://send.estate/s?e=8d2b330455d4fcb

In your task sequence have 2 run commands using the package

xcopy /s *.jpg %windir%WebWallpaperHappySCCM /y

cscript.exe SetBackground.vbs

You can also modify the last section of the code, if the resolution doesn't match it uses the BackgroundDefault1920x1080.jpg, rename that to an image that scales well.

 

Adding custom programs to the Set Default Programs UI

Capture

Hi, today I wanted the CMTrace tool to be recognised in the Set Default Programs control panel applet. There is a bit of information on the net but it's confusing.

In the registry you can set the program, launch arguments, file types and icon. This can be used for any app by modifying the reg file.

 

Download reg file

 

Once added you may like to use DISM.exe to extract your chosen defaults and import during your task sequence.

Dism /Online /Export-DefaultAppAssociations:Defaults.xml
Dism /Online /Import-DefaultAppassociations:Defaults.xml